hugo/content/hosting-and-deployment/hosting-on-gitlab.md
Bjørn Erik Pedersen 2c0d1ccdcd Squashed 'docs/' changes from b0470688..73f355ce
73f355ce Update theme
83ff50c2 Use example.com in examples
71292134 Add alias news > release-notes
2e15f642 Update theme
8eef09d2 Add Pygments configuration
572b9e75 Clean up the code shortcode use
a1b2fd3b Remove the code fence language codes
1473b1d9 Remove redundant text
b92c2042 Update theme
8f439c28 Edit contributing section in README
8bcf8a19 Add contributing section to README
4c44ee1c Fix broken content file
2bdc7710 Clarify .Data.Pages sorting in lists.md
092271c2 Use infinitive mood for main titles
b9b8abef Update theme to reflect change to home page content
b897b71b Change copy to use sentence case
fd675ee5 Enable RSS feed for sections
060a5e27 Correct movie title in taxonomies.md
6a5ca96a Update displayed site name for Hub
22f4b7a4 Add example of starting up the local server
d9612cb3 Update theme
a8c3988a Update theme
4198189d Update theme
12d6b016 Update theme
2b1c4197 Update theme
b6d90a1e Fix News release titles
cfe751db Add some build info to README

git-subtree-dir: docs
git-subtree-split: 73f355ce0dd88d032062ea70067431ab980cdd8d
2017-07-21 11:00:08 +02:00

2.5 KiB

title linktitle description date publishdate lastmod categories authors menu weight sections_weight draft toc wip aliases
Host on GitLab Host on GitLab GitLab makes it incredibly easy to build, deploy, and host your Hugo website via their free GitLab Pages service, which provides native support for Hugo. 2016-06-23 2016-06-23 2016-06-23
hosting and deployment
Riku-Pekka Silvola
docs
parent weight
hosting-and-deployment 40
40 40 false true false
/tutorials/hosting-on-gitlab/

GitLab makes it incredibly easy to build, deploy, and host your Hugo website via their free GitLab Pages service, which provides native support for Hugo, as well as numerous other static site generators.

Assumptions

  • Working familiarity with Git for version control
  • Completion of the Hugo Quick Start
  • A GitLab account
  • A Hugo website on your local machine that you are ready to publish

Create .gitlab-ci.yml

cd your-hugo-site

In the root directory of your Hugo site, create a .gitlab-ci.yml file. The .gitlab-ci.yml configures the GitLab CI on how to build your page. Simply add the content below.

{{< code file="gitlab-ci.yml" >}} image: publysher/hugo

pages: script:

  • hugo artifacts: paths:
    • public only:
  • master {{< /code >}}

Push Your Hugo Website to GitLab

Next, create a new repository on GitLab. It is not necessary to make the repository public. In addition, you might want to add /public to your .gitignore file, as there is no need to push compiled assets to GitLab or keep your output website in version control.

# initialize new git repository
git init

# add /public directory to our .gitignore file
echo "/public" >> .gitignore

# commit and push code to master branch
git add .
git commit -m "Initial commit"
git remote add origin https://gitlab.com/YourUsername/your-hugo-site.git
git push -u origin master

Wait for Your Page to Build

That's it! You can now follow the CI agent building your page at https://gitlab.com///pipelines.

After the build has passed, your new website is available at https://<YourUsername>.gitlab.io/<your-hugo-site>/.

Next Steps

GitLab supports using custom CNAME's and TLS certificates. For more details on GitLab Pages, see the GitLab Pages setup documentation.