Example Hugo website using GitLab Pages.
Learn more about GitLab Pages at the official documentation.
This project's static Pages are built by GitLab CI/CD,
following the steps defined in .gitlab-ci.yml
.
To work locally with this project, you'll have to follow the steps below:
-
Fork, clone or download this project.
-
Install
git
andgo
. -
Install Hugo.
-
Install the theme as a Hugo module:
hugo mod init gitlab.com/pages/hugo hugo mod get -u github.com/theNewDynamic/gohugo-theme-ananke
-
Preview your project:
hugo server
-
Add content.
-
Optional. Generate the website:
hugo
Read more at Hugo's documentation.
Hugo supports a variety of themes.
Visit https://themes.gohugo.io/ and pick the theme you want to use. In the Pages example, we use https://themes.gohugo.io/themes/gohugo-theme-ananke/.
The example .gitlab-ci.yml
uses Hugo modules to import the theme.
To use your own theme:
-
Edit
.gitlab-ci.yml
, and replace the URL in thehugo mod get
line with the URL of your theme:- hugo mod get -u github.com/theNewDynamic/gohugo-theme-ananke
-
Edit
config.toml
and add the theme:theme = ["github.com/theNewDynamic/gohugo-theme-ananke"]
The Container Registry
contains two kinds of Hugo Docker images, hugo
and
hugo_extended
. Their main difference is that hugo_extended
comes with
Sass/SCSS support. If you don't know if your theme supports it, it's safe to
use hugo_extended
since it's a superset of hugo
.
The Container Registry contains three repositories:
registry.gitlab.com/pages/hugo
registry.gitlab.com/pages/hugo/hugo
registry.gitlab.com/pages/hugo/hugo_extended
pages/hugo:<version>
and pages/hugo/hugo:<version>
are effectively the same.
hugo_extended
was created afterwards, so we had to create the pages/hugo/
namespace.
See how the images are built and deployed.
To use this project as your user/group website, you will need to perform some additional steps:
- Rename your project to
namespace.gitlab.io
, wherenamespace
is yourusername
orgroupname
. This can be done by navigating to your project's Settings > General (Advanced). - Change the
baseurl
setting in yourconfig.toml
, from"https://pages.gitlab.io/hugo/"
tobaseurl = "https://namespace.gitlab.io"
. Proceed equally if you are using a custom domain:baseurl = "https://example.com"
.
Read more about GitLab Pages for projects and user/group websites.
If you forked this project for your own use, please go to your project's Settings and remove the forking relationship, which won't be necessary unless you want to contribute back to the upstream project.
- Either that you have wrongly set up the CSS URL in your templates.
- Or your static generator has a configuration option that needs to be explicitly set in order to serve static assets under a relative URL.
If the version of hugo
or hugo_extended
is 0.92.2 or later, you may have problems building the website.
Generics were introduced in Go 1.18, and they broke some features in the newer versions of Hugo. For now, if you use hugo
or hugo_extended
versions 0.92.2 or later, you might encounter problems building the website. To resolve the problem:
- Edit your
.gitlab-ci.yaml
file. - Identify the line that declares the Hugo version.
- Change the value to
:0.92.2
. - Save your changes
For more information about this issue:
- This issue is tracked in Gitlab Hugo template fails CI/CD build with "latest" docker version.
- For discussions about fixing the problem in Hugo, and proposals to potentially resolve these issues, read proposal: spec: allow type parameters in methods.