How to create static blog using GitLab pages
Some instructions still might be useful.
- Go to GitLab and register there if you have not yet. I prefer GitLab over GitHub for several reasons:
- you can have pages for a private repository (and set access control for them) - GitHub allows you to only have public pages for a public repository or private pages for private repository when you have enterprise account.
- GitLab has integrated CI/CD automation you can immediately use
- Ukrainian origin :)
- Create a new repository, “blog” for example. GitLab has several templates you can use to create a new repo, including Hugo blog template, but I found it containing too much. Therefore I’ve created an empty repository just with README there.
- Configure pages for the repo:
- Settings -> Pages: enable pages, optionally add own domain.
- Settings -> General -> Visibility, project features, permissions -> Pages: enable for everyone.
- git clone …
- add “.gitlab-ci.yml” automation file to the repo:
# All available Hugo versions are listed here: https://gitlab.com/pages/hugo/container_registry
image: registry.gitlab.com/pages/hugo:latest
variables:
GIT_SUBMODULE_STRATEGY: recursive
test:
script:
- hugo
except:
- master
pages:
variables:
- HUGO_ENV: production
script:
- hugo
artifacts:
paths:
- public
only:
- master
- Follow instructions to install Hugo, add template, create a post.
- Push it!