hugo/content/hosting-and-deployment/hosting-on-gitlab.md
Bjørn Erik Pedersen 374d184e67 Squashed 'docs/' changes from f97826a17..1dc05a16b
1dc05a16b Update index.md
d73a9b3b4 Added StackImpact showcase
b0e82b3a5 Fix uglyURLs example
cf8a93728 GA track outgoing sponsor clikcs
aca59ac66 Move the sponsor banners up a little
5571673f0 Migrate from analytics.js to gtag.js
64a29b6cb Update faq.md
84704aa84 Use GOPATH variable if defined in installation from source
5f70e6ee2 Remove disableRSS etc. from the documentation
4945e7937 Remove superflous asterisks
39f6c9c28 showcase: Add 1password.com
fe0f82610 Add GitLab warning
9f26f21d2 Fix URL typo
83a91fc99 Remove duplicate release notes
133cdd313 Release 0.36.1
fbe2a2dc7 Clean images
1b02f9193 Merge branch 'temp361'
c430d2d58 Merge branch 'release-0.36.1'
dd7370fc4 releaser: Prepare repository for 0.37-DEV
72534f9ec releaser: Add release notes to /docs for release of 0.36.1
845b2cacb releaser: Bump versions for release of 0.36.1
78790fcb1 Add fluid type to showcase details box
4ef59e008 Adjust column widths to handle a wider variety of copy width
6d2e68521 Always show the latest showcase item on front page
665b1eb5e showcase: Shuffle the news items
5fef1f9b7 Escape quote
d680f0c16 Add some quotes
1722f0d5a showcase: Make the description more about Hugo
a9d43db0a Add Quiply Employee Communications App
7aaa464ec Add Quiply Employee Communications App
fad6a25dd maintenance: Show last 30
7afcfdced showcase: Set Linode date to today
0c31f481a New showcase for Linode
6c7687c2d Minor edits to the `apply` documentation
04bbff8b3 Update apply.md
f543032e3 Fix clunky sentence
218ba2a65 Some more Netlify improvements
0bd512125 Improve the Netlify versioning docs
7a708d60e Clarify Netlify's Hugo versions handling
8f86342cd Add some space
d68d4ff37 Remove now superflous warning
bf93a46ea maintenance: Add TODO list
3b5f27835 maintenance: Remove a superflous prefix
8f29ba2fb maintenance: Adjust order
105d53610 maintenance: Add TOC
29e86396b maintenance: Fix page list selection
ba51fe66d Finish the Maintenance  section
e9b0c710c Add latest changes in new spotlight section
8ccd79f61 Fix broken sentence
c77643c37 Spelling
919f2faef Remove some old troubleshooting articles
09e467f06 Add a new FAQ
ac2b25bb5 Hartwell showcase typos
5bf766993 Trim "www." from shocase URLs in title
a180cd5cb Make the inline showcase template names unique
6886982fd Merge commit '9cc9bab46288d8d5f9fda7009c5f746258cec1b4'
09728efbf Add "target" and "rel" parameters to figure shortcode

git-subtree-dir: docs
git-subtree-split: 1dc05a16bd6b99809d97daeda743d914297f908c
2018-02-21 10:00:31 +01:00

92 lines
2.9 KiB
Markdown

---
title: Host on GitLab
linktitle: Host on GitLab
description: 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.
date: 2016-06-23
publishdate: 2016-06-23
lastmod: 2017-11-16
categories: [hosting and deployment]
keywords: [hosting,deployment,git,gitlab]
authors: [Riku-Pekka Silvola]
menu:
docs:
parent: "hosting-and-deployment"
weight: 40
weight: 40
sections_weight: 40
draft: false
toc: true
wip: false
aliases: [/tutorials/hosting-on-gitlab/]
---
{{% warning %}}
GitLab has temporarily turned off custom domains support because of a security issue. The plan is to re-enable it after the 20th of February.
For more information:
https://about.gitlab.com/2018/02/05/gitlab-pages-custom-domain-validation/
{{% /warning %}}
{{< todo >}}Remove the above when fixed.{{< /todo >}}
[GitLab](https://gitlab.com/) 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](https://gitlab.com/pages/hugo).
## Assumptions
* Working familiarity with Git for version control
* Completion of the Hugo [Quick Start][]
* A [GitLab account](https://gitlab.com/users/sign_in)
* 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: monachus/hugo
variables:
GIT_SUBMODULE_STRATEGY: recursive
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/<YourUsername>/<your-hugo-site>/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](https://about.gitlab.com/2016/04/07/gitlab-pages-setup/).
[Quick Start]: /getting-started/quick-start/