BitBucket Hosting
BitBucket icon

Free hosting on BitBucket

Note if you have any dyanmic pages (eg. are using php) then you will need to use an alternative for hosting.

Information on BitBucket pages may be found here and here.

Importing/Forking an existing website repository

By far the easiest way to host a website on BitBucket is to import or fork an existing site repository from BitBucket or any other code sharing platform. See here for a variety of templates you can use to make websites.

Simple BitBucket setup

This section has simple instructions for hosting your site for free on BitBucket. Further below are more advanced instructions for setting up the stage directory and site directory as branches in the same repository.

On BitBucket with url:
https://username.BitBucket.io

  1. If you do not already have a BitBucket account, you can join here;
  2. If you do not already have Git installed on your computer, you can find installation instructions here and a tutorial for using Git with BitBucket here;
    Note: If you are new to Git and BitBucket, do not confuse yourself about authenticating with BitBucket from Git. You can follow the rest of these steps and educate yourself later.
  3. Create a new repository called username.bitbucket.io, where username is your BitBucket username;
  4. Open a terminal window and change to the directory you would like to store your repository in locally;
  5. Clone a local copy of your new repository by entering:
    git clone https://bitbucket.com/username/username.bitbucket.io.git
    
  6. Change into the repository directory by entering cd username.bitbucket.io;
  7. Copy your site files (anything inside the site directory, not the whole stage directory) into the repository directory;
  8. Enter the following into your terminal window:
    git status
    git add .
    git commit -m "added site files"
    git push origin master
    

  9. Your site, with url:
    https://username.bitbucket.io
    
    should now be hosted and accessible from the internet.

To update your site, just repeat the steps following (and including) copying the site files into the repository directory.

On BitBucket with url:
https://username.bitbucket.io/site-name

  1. If you do not already have a BitBucket account, you can join here;
  2. If you do not already have Git installed on your computer, you can find installation instructions here and a tutorial for using Git with BitBucket here;
    Note: If you are new to Git and BitBucket, do not confuse yourself about authenticating with BitBucket from Git. You can follow the rest of these steps and educate yourself later.
  3. BitBucket is slightly different to both GitHub and GitLab here, the only way to really do this is to add the site to your personal site repository, ie. add the site to what is being tracked for the username.bitbucket.io repository. For example you might have nsm track content/site-name/index to track an index page that appears to be a separate site hosted at:
    https://username.bitbucket.io/site-name
    

Advanced BitBucket setup

This section has advanced instructions for hosting your site for free on BitBucket. We will setup two branches, one for the stage directory and another for the site directory. Locally we will also have the branch for the site directory inside the branch for the stage directory. This is a little confusing at first, but is super useful once it makes sense.

Once you already have a repository set up for this and you want to make a new local clone I typically (I may add a command to nsm to automate the following at some point):

  1. clone the repository from BitBucket;
  2. switch to the master branch if necessary;
  3. rename the directory to site;
  4. clone the repository from BitBucket again (if the size of your repository is large enough that downloading it twice is slow/tiresome/wasteful then just make a local copy the first time you clone it);
  5. switch to the stage branch if necessary;
  6. remove the copy of the site directory from the stage directory/branch and move the site directory/branch in to the stage directory/branch.

I would love to know if someone finds an easier way to achieve the same result below.

On BitBucket with url:
https://username.bitbucket.io

  1. If you do not already have a BitBucket account, you can join here;
  2. If you do not already have Git installed on your computer, you can find installation instructions here and a tutorial for using Git with BitBucket here;
    Note: If you are new to Git and BitBucket, do not confuse yourself about authenticating with BitBucket from Git. You can follow the rest of these steps and educate yourself later.
  3. Create a new repository called username.bitbucket.io, where username is your BitBucket username;
  4. Open a terminal window and change to the directory you would like to store your repository in locally;
  5. Clone a local copy of your new repository by entering:
    git clone https://bitbucket.com/username/username.bitbucket.io.git
    
  6. Change into the repository directory by entering cd username.bitbucket.io;
  7. Checkout a new branch called stage by entering git checkout -b stage;
  8. Copy your stage files (anything inside the stage directory, including the site directory) into the repository directory;
  9. Enter the following into your terminal window:
    git status
    git add .
    git commit -m "setup stage branch"
    git push origin stage
    

  10. Change to the parent of your repository directory by entering cd ..
  11. Rename your repository directory from username.bitbucket.io to username.bitbucket.io-stage
  12. Make a second local clone of your repository by again entering:
    git clone https://bitbucket.com/username/username.bitbucket.io.git
    
  13. Change into the second local repository directory by again entering cd username.bitbucket.io;
  14. Checkout an orphan branch called master by entering git checkout --orphan master;
  15. Delete everything inside the second local copy of your repository;
  16. Enter git rm -r .
  17. Enter git status and ensure you get:
    On branch master
    
    Initial commit
    
    nothing to commit (create/copy files and use "git add" to track)
    

  18. Copy the site files (anything inside the site directory, not the stage directory) from the first local copy of your repository (ie. files in username.bitbucket.io-stage/site/) to the second local copy of your repository (ie. place them in username.bitbucket.io, not username.bitbucket.io/site/);
  19. Enter the following into your terminal window:
    git status
    git add .
    git commit -m "setup master branch"
    git push origin master
    

    Your site, with url:

    https://username.bitbucket.io
    
    should now be hosted and accessible from the internet.

  20. Change to the parent of your (second) repository directory by entering cd ..
  21. Rename your second repository directory from username.bitbucket.io to site
  22. Move your second repository directory, now named site, into your first repository directory (replacing the copy of site already in the first repository directory);
Now from your local repository, you can manage the site/master branch from inside the site directory, and the stage branch from anywhere else inside the repository. Give it a try, I think you will like it!

On BitBucket with url:
https://username.bitbucket.io/site-name

  1. If you do not already have a BitBucket account, you can join here;
  2. If you do not already have Git installed on your computer, you can find installation instructions here and a tutorial for using Git with BitBucket here;
    Note: If you are new to Git and BitBucket, do not confuse yourself about authenticating with BitBucket from Git. You can follow the rest of these steps and educate yourself later.
  3. BitBucket is again slightly different to both GitHub and GitLab here, the only way to really do this is to add the site to your personal site repository, ie. add the site to what is being tracked for the username.bitbucket.io repository. For example you might have nsm track content/site-name/index to track an index page that appears to be a separate site hosted at:
    https://username.bitbucket.io/site-name