github.com/shohhei1126/hugo@v0.42.2-0.20180623210752-3d5928889ad7/docs/content/en/hosting-and-deployment/hosting-on-bitbucket.md (about) 1 --- 2 title: Host on Bitbucket 3 linktitle: Host on Bitbucket 4 description: You can use Bitbucket in conjunction with Aerobatic to build, deploy, and host a Hugo website. 5 date: 2017-02-04 6 publishdate: 2017-02-04 7 lastmod: 2017-02-04 8 categories: [hosting and deployment] 9 keywords: [hosting,bitbucket,deployment,aerobatic] 10 authors: [Jason Gowans] 11 menu: 12 docs: 13 parent: "hosting-and-deployment" 14 weight: 50 15 weight: 50 16 sections_weight: 50 17 draft: false 18 toc: true 19 aliases: [/tutorials/hosting-on-bitbucket/] 20 --- 21 22 You can use [Bitbucket](https://bitbucket.org/) and [Aerobatic](https://www.aerobatic.com) to build, deploy, and host a Hugo website. Aerobatic is a static hosting service that integrates with Bitbucket and provides a free hosting tier. 23 24 ## Assumptions 25 26 * Working familiarity with Git for version control 27 * A [Bitbucket account](https://bitbucket.org/account/signup/) 28 29 ## Install Aerobatic CLI 30 31 If you haven't previously used Aerobatic, you'll first need to install the Command Line Interface (CLI) and create an account. For a list of all commands available, see the [Aerobatic CLI](https://www.aerobatic.com/docs/cli/) docs. 32 33 ``` 34 npm install aerobatic-cli -g 35 aero register 36 ``` 37 38 ## Create and Deploy Site 39 40 ``` 41 hugo new site my-new-hugo-site 42 cd my-new-hugo-site 43 cd themes; git clone https://github.com/eliasson/liquorice 44 hugo -t liquorice 45 aero create # create the Aerobatic site 46 hugo --baseURL https://my-new-hugo-site.aerobatic.io # build the site overriding baseURL 47 aero deploy -d public # deploy output to Aerobatic 48 49 Version v1 deployment complete. 50 View now at https://hugo-docs-test.aerobatic.io 51 ``` 52 53 In the rendered page response, the `https://__baseurl__` will be replaced with your actual site url (in this example, `https://my-new-hugo-site.aerobatic.io`). You can always rename your Aerobatic website with the `aero rename` command. 54 55 ## Push Hugo site to Bitbucket 56 57 We will now create a git repository and then push our code to Bitbucket. In Bitbucket, create a repository. 58 59 ![][1] 60 61 [1]: /images/hosting-and-deployment/hosting-on-bitbucket/bitbucket-create-repo.png 62 63 64 ``` 65 # initialize new git repository 66 git init 67 68 # set up our .gitignore file 69 echo -e "/public \n/themes \naero-deploy.tar.gz" >> .gitignore 70 71 # commit and push code to master branch 72 git add --all 73 git commit -m "Initial commit" 74 git remote add origin git@bitbucket.org:YourUsername/my-new-hugo-site.git 75 git push -u origin master 76 ``` 77 78 ## Continuous Deployment With Bitbucket Pipelines 79 80 In the example above, we pushed the compiled assets in the `/public` folder to Aerobatic. In the following example, we use Bitbucket Pipelines to continuously create and deploy the compiled assets to Aerobatic. 81 82 ### Step 1: Configure Bitbucket Pipelines 83 84 In your Hugo website's Bitbucket repo; 85 86 1. Click the Pipelines link in the left nav menu of your Bitbucket repository. 87 2. Click the Enable Pipelines button. 88 3. On the next screen, leave the default template and click Next. 89 4. In the editor, paste in the yaml contents below and click Commit. 90 91 ``` 92 image: beevelop/nodejs-python 93 pipelines: 94 branches: 95 master: 96 - step: 97 script: 98 - apt-get update -y && apt-get install wget 99 - apt-get -y install git 100 - wget https://github.com/gohugoio/hugo/releases/download/v0.18/hugo_0.18-64bit.deb 101 - dpkg -i hugo*.deb 102 - git clone https://github.com/eliasson/liquorice themes/liquorice 103 - hugo --theme=liquorice --baseURL https://__baseurl__ --buildDrafts 104 - npm install -g aerobatic-cli 105 - aero deploy 106 ``` 107 108 ### Step 2: Create `AEROBATIC_API_KEY` environment variable. 109 110 This step only needs to be done once per account. From the command line; 111 112 ``` 113 aero apikey 114 ``` 115 116 1. Navigate to the Bitbucket account settings for the account that the website repo belongs to. 117 2. Scroll down to the bottom of the left nav and click the Environment variables link in the PIPELINES section. 118 3. Create a new environment variable called AEROBATIC_API_KEY with the value you got by running the `aero apikey` command. Be sure to click the Secured checkbox. 119 120 ### Step 3: Edit and Commit Code 121 122 ``` 123 hugo new post/good-to-great.md 124 hugo server --buildDrafts -t liquorice #Check that all looks good 125 126 # commit and push code to master branch 127 git add --all 128 git commit -m "New blog post" 129 git push -u origin master 130 ``` 131 132 Your code will be committed to Bitbucket, Bitbucket Pipelines will run your build, and a new version of your site will be deployed to Aerobatic. 133 134 At this point, you can now create and edit blog posts directly in the Bitbucket UI. 135 136 ![][2] 137 138 [2]: /images/hosting-and-deployment/hosting-on-bitbucket/bitbucket-blog-post.png 139 140 141 ## Suggested next steps 142 143 The code for this example can be found in this Bitbucket [repository](https://bitbucket.org/dundonian/hugo-docs-test). Aerobatic also provides a number of additional [plugins](https://www.aerobatic.com/docs) such as auth and redirects that you can use for your Hugo site.