You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gitlab-pages.md 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. +++
  2. title = "GitLab Pages"
  3. weight = 30
  4. +++
  5. We are going to use the GitLab CI runner to automatically publish the site (this CI runner is already included in your repository if you use GitLab.com).
  6. ## Repository setup
  7. Your repository needs to be set up to be a user or group website. This means the name of the repository has to be in the correct format.
  8. For example, assuming that the username is `john`, you have to create a project called `john.gitlab.io`. Your project URL will be `https://gitlab.com/john/john.gitlab.io`. Once you enable GitLab Pages for your project, your website will be published under `https://john.gitlab.io`.
  9. Under your group `websites`, you created a project called `websites.gitlab.io`. Your project’s URL will be `https://gitlab.com/websites/websites.gitlab.io`. Once you enable GitLab Pages for your project, your website will be published under `https://websites.gitlab.io`.
  10. This guide assumes that your zola project is located in the root of your repository.
  11. ## Ensuring that the CI runner can access your theme
  12. Depending on how you added your theme, your repository may not contain it. The best way to ensure that the theme will
  13. be added is to use submodules. When doing this, ensure that you are using the `https` version of the URL.
  14. ```shell
  15. $ git submodule add {THEME_URL} themes/{THEME_NAME}
  16. ```
  17. For example, this could look like:
  18. ```shell
  19. $ git submodule add https://github.com/getzola/hyde.git themes/hyde
  20. ```
  21. ## Setting up the GitLab CI/CD Runner
  22. The second step is to tell the GitLab continous integration runner how to create the GitLab page.
  23. To do this, create a file called `.gitlab-ci.yml` in the root directory of your repository.
  24. ```yaml
  25. variables:
  26. # This variable will ensure that the CI runner pulls in your theme from the submodule
  27. GIT_SUBMODULE_STRATEGY: recursive
  28. # Specify the zola version you want to use here
  29. ZOLA_VERSION: "v0.9.0"
  30. pages:
  31. script:
  32. # Download the zola executable and store it in zola.tar.gz
  33. - curl -L https://github.com/getzola/zola/releases/download/$ZOLA_VERSION/zola-$ZOLA_VERSION-x86_64-unknown-linux-gnu.tar.gz > zola.tar.gz
  34. # Unpack the zola executable
  35. - tar -xzf zola.tar.gz
  36. # Execute zola build
  37. - ./zola build
  38. artifacts:
  39. paths:
  40. # Path of our artifacts
  41. - public
  42. # This config will only publish changes that are pushed on the master branch
  43. only:
  44. - master
  45. ```
  46. Push this new file and ... Tada! You're done! If you navigate to `settings > pages`, you should be able to see
  47. something like this:
  48. > Congratulations! Your pages are served under:
  49. https://john.gitlab.io
  50. More information on the process to host on GitLab pages and additional information like using a custom domain is documented
  51. [in this GitLab blog post](https://about.gitlab.com/2016/04/07/gitlab-pages-setup/).