You can use Bitbucket to host a static website, which would be accessed at
<workspaceid>.bitbucket.io. (What's a workspace?)
A static website contains coded HTML pages with fixed content. Websites hosted in this way will have the
bitbucket.io domain in their URL. For example, if the workspace ID for a repository was
tutorials, you would set the Repository name to
Set up a static website hosted on Bitbucket Cloud
To publish a static website on Bitbucket Cloud, you combine your workspace ID with the
bitbucket.io domain suffix as your repository name. Your workspace ID must be acceptable by DNS standards. Each workspace can have only one site hosted on bitbucket.io.
To set up a static website hosted on bitbucket.io:
From within Bitbucket, create a repository, and have the Repository name use the scheme
Clone the repository to your local system.
Create a file called
index.htmlin the repository root directory, in lowercase letters. Uppercase and special characters are not permitted.Why lowercase?
Filenames are case sensitive; Bitbucket treats
Index.htmlas different file names.
- Create a file named
index.htmlin your repository, add some content, commit the change, then push the change to Bitbucket.
Navigate to the
site. Bitbucket displays the HTML in the site's
For a workspace with the ID
tutorialsyou would navigate to
Functionality and limitations of this feature
Static websites on Bitbucket support the following functionality:
- Embedding images and other media.
- Blog comments by embedding Disqus in your site.
This turns a repository into a static web server that uses the repository's root as the web root. This leads to some limitations:
- For information on Bitbucket Cloud repository and file size limits, see What kind of limits do you have on repository/file size?
- HTTPS is required for bitbucket.io, for your security.
- The system does not issue cookies.
- Server-side scripts or code are not supported. For example, PHP is not available.
- Each page will be cached for 15 minutes. So your changes might not be visible immediately.
- Uppercase characters and special characters are not permitted.
- Cannot use special characters: underscores are not allowed in DNS hostnames.
Finally, we inject a
rum.js script into each Bitbucket website. This script captures internal web analytics and statistics.
Host multiple files under a single website
You may have multiple files that you want to host from the same Bitbucket websites, you can do this by placing each file in a repository subdirectory. In this example, you would want to organize things like this:
Each subdirectory would act as a self-contained website with its own
Bitbucket is forgiving with regard to trailing slashes: a request to
https://workspace_ID.bitbucket.io/projectX/ will result in
projectX/index.html being served (if such a file exists), regardless of whether the trailing slash is included in the URL.
While you can use subdirectories to manage different files, each static site will generate from the main branch of the repository. Master is the default main branch (you can change this in the repository settings). Bitbucket only generates content from the selected main branch.
Public and private repositories and static websites
The static website you create with this feature is just like any other website on the Internet — anyone with the URL can visit and view your static website. The underlying Bitbucket repository can be a public or a private repository. This means if your Bitbucket repository is private, users can still visit and view the static website. The same is true if the underlying repository is public.