GitLab Pages

We are going to use the GitLab Runner in GitLab CI/CD to host the site on GitLab Pages.

🔗Configuring your repository

It is possible to host your Zola site on either the SaaS instance offered by GitLab ( or on a self-hosted instance.

It is recommended to create a repository on GitLab that contains solely your Zola project. The Zola's directory structure should be located in the root directory of your repository.

For information on how to create and manage a repository on GitLab, refer to:

🔗Ensuring that the runner can access your theme

Depending on how you added your theme, your repository may not contain it. The best way to ensure that the theme will be added is to use submodules. When doing this, ensure that you are using the https version of the URL.

git submodule add {THEME_URL} themes/{THEME_NAME}

For example, this could look like:

git submodule add themes/hyde

🔗Setting up the GitLab Runner

The GitLab Runner needs to know how to create your site in order to deploy it to the GitLab Pages server.

We provide you with a template to accomplish this task easily. Create a file called .gitlab-ci.yml in the root directory of your repository and copy the contents of the template below.

  - deploy

  image: debian:stable-slim
    - docker

  # The runner will be able to pull your Zola theme when the strategy is
  # set to "recursive".

  # If you don't set a version here, your site will be built with the latest
  # version of Zola available in GitHub releases.
  # Use the semver (x.y.z) format to specify a version. For example: "0.17.2" or "0.18.0".
    description: "The version of Zola used to build the site."
    value: ""

  stage: deploy
    - |
      apt-get update --assume-yes && apt-get install --assume-yes --no-install-recommends wget ca-certificates
      if [ $ZOLA_VERSION ]; then
        if ! wget --quiet --spider $zola_url; then
          echo "A Zola release with the specified version could not be found.";
          exit 1;
          wget --output-document - $github_api_url |
          grep "browser_download_url.*linux-gnu.tar.gz" |
          cut --delimiter : --fields 2,3 |
          tr --delete "\" "
      wget $zola_url
      tar -xzf *.tar.gz
      ./zola build

      # This is the directory whose contents will be deployed to the GitLab Pages
      # server.
      # GitLab Pages expects a directory with this name by default.
      - public

    # This rule makes it so that your website is published and updated only when
    # you push to the default branch of your repository (e.g. "master" or "main").

Please, keep in mind that this template assumes you are using the Docker executor on your GitLab Runner. Feel free to adjust the file to your workflow and specific requirements.

After you push this file to the default branch of your repository (e.g. "master" or "main"), your site will be ready. The GitLab CI/CD pipelines will ensure your site is published and updated automatically.

On the left sidebar of GitLab, navigate to Deploy > Pages to find the URL of your website inside the Access pages section.

More information on how to host your site on GitLab Pages is available in the official GitLab documentation.