4 KiB
authors | lastmod | date | linktitle | toc | menu | next | prev | title | weight | |||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
2016-03-11 | 2016-03-11 | Hosting on Bitbucket | true |
|
/tutorials/github-pages-blog | /tutorials/creating-a-new-theme | Continuous deployment with Bitbucket & Aerobatic | 10 |
Continuous deployment with Bitbucket & Aerobatic
Introduction
In this tutorial, we will use Bitbucket and Aerobatic to build, deploy, and host a Hugo site. Aerobatic is a static hosting service that is installed as an add-on to Bitbucket and provides a free hosting tier with custom domain and wildcard SSL certificate.
It is assumed that you know how to use git for version control and have a Bitbucket account. It is also assumed that you have gone through the [quickstart guide]({{< relref "overview/quickstart.md" >}}) and already have a Hugo site on your local machine.
Create package.json
cd your-hugo-site
In the root directory of your Hugo site, create a package.json
file. The package.json
informs Aerobatic to build a Hugo site.
To do so, declare the following snippet in your package.json
manifest. You can, of course, use any Hugo theme of your choosing with the themeRepo
option. Just tell Aerobatic where the theme’s git repo is.
{
"_aerobatic": {
"build": {
"engine": "hugo",
"themeRepo": "https://github.com/alexurquhart/hugo-geo.git"
}
}
}
Push Hugo site to Bitbucket
We will now create a git repository and then push our code to Bitbucket. Because Aerobatic both builds and hosts Hugo sites, there is no need to push the compiled assets in the /public
folder.
# initialize new git repository
git init
# add /public directory to our .gitignore file
echo "/public" >> .gitignore
# commit and push code to master branch
git commit -a -m "Initial commit"
git remote add origin git@bitbucket.org:YourUsername/your-hugo-site.git
git push -u origin master
Install Aerobatic
Clicking this link will automatically install the Aerobatic add-on to your Bitbucket account. Alternatively, you can also install Aerobatic from the Bitbucket add-on directory. Click Grant Access in the install dialog.
Setup hosting
Select your repository from the dropdown menu and click Setup hosting
You will then be directed to the Create Website screen. This is a one-time step. With each subsequent git push
to Bitbucket, Aerobatic will automatically build and deploy a new version of your site instantly.
- Give your website a name.
- In this example, we won't setup a custom domain, but you can.
- Leave the deploy branch as master.
Click the Create website button:
In less than 30 seconds, your Hugo site will be built and live on the Internet at http://your-hugo-site.aerobatic.io
Suggested next steps
The code for this example can be found in this Bitbucket repository.
Aerobatic provides a number of plugins such as custom error pages, custom redirects, basic authentication, and many other features. In the case of authentication, this blog post describes how to password protect all, or part, of your Hugo site.