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
https://username.BitBucket.io
- If you do not already have a BitBucket account, you can join here;
-
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. -
Create a new repository called
username.bitbucket.io , whereusername is your BitBucket username; - Open a terminal window and change to the directory you would like to store your repository in locally;
-
Clone a local copy of your new repository by entering:
git clone https://bitbucket.com/username/username.bitbucket.io.git
-
Change into the repository directory by entering
cd username.bitbucket.io ; - Copy your site files (anything inside the site directory, not the whole stage directory) into the repository directory;
-
Enter the following into your terminal window:
git status git add . git commit -m "added site files" git push origin master
-
Your site, with url:
https://username.bitbucket.io
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
https://username.bitbucket.io/site-name
- If you do not already have a BitBucket account, you can join here;
-
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. -
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 havensm 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):
- clone the repository from BitBucket;
- switch to the
master branch if necessary; - rename the directory to
site ; - 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);
- switch to the
stage branch if necessary; - remove the copy of the
site directory from thestage directory/branch and move thesite directory/branch in to thestage 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
https://username.bitbucket.io
- If you do not already have a BitBucket account, you can join here;
-
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. -
Create a new repository called
username.bitbucket.io , whereusername is your BitBucket username; - Open a terminal window and change to the directory you would like to store your repository in locally;
-
Clone a local copy of your new repository by entering:
git clone https://bitbucket.com/username/username.bitbucket.io.git
-
Change into the repository directory by entering
cd username.bitbucket.io ; -
Checkout a new branch called
stage by enteringgit checkout -b stage ; - Copy your stage files (anything inside the stage directory, including the site directory) into the repository directory;
-
Enter the following into your terminal window:
git status git add . git commit -m "setup stage branch" git push origin stage
-
Change to the parent of your repository directory by entering
cd .. -
Rename your repository directory from
username.bitbucket.io tousername.bitbucket.io-stage -
Make a second local clone of your repository by again entering:
git clone https://bitbucket.com/username/username.bitbucket.io.git
-
Change into the second local repository directory by again entering
cd username.bitbucket.io ; -
Checkout an orphan branch called
master by enteringgit checkout --orphan master ; - Delete everything inside the second local copy of your repository;
-
Enter
git rm -r . -
Enter
git status and ensure you get: On branch master Initial commit nothing to commit (create/copy files and use "git add" to track)
-
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 inusername.bitbucket.io , notusername.bitbucket.io/site/ ); -
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
-
Change to the parent of your (second) repository directory by entering
cd .. -
Rename your second repository directory from
username.bitbucket.io tosite -
Move your second repository directory, now named
site , into your first repository directory (replacing the copy ofsite already in the first repository directory);
On BitBucket with url:
https://username.bitbucket.io/site-name
https://username.bitbucket.io/site-name
- If you do not already have a BitBucket account, you can join here;
-
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. -
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 havensm 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