Gitlab Pages with Static Site Generators (Pelican)

Posted on Wed 02 January 2019 in Static Site Generator • 2 min read

Taking into account that in the last billing period, Google has billed me € 24 for this website with 3 static pages, without database and with very little traffic, which is generated with Pelican, I have decided to move lnxnet.es to gitlab pages.

So be careful with the Google app engine and the costs, since the terms ALWAYS FREE are not very clear and when you finish the trial period they start to invoice you, even it was quite complicated to be able to delete the project so that it did not continue generating costs.

To create a static site in gitlab-pages you have to choose between the diferents Static Site Generator (SSG):

As lnxnet.es was generated the first time with Pelican, this tutorial will be based on this SGG


To use GitLab Pages, first you need to create a project in GitLab to upload your website’s files to. These projects can be either public, internal, or private, at your own choice, so first you need a Gitlab.com account, it's free https://gitlab.com/users/sign_in

For getting started you can go to https://gitlab.com/pages and choose among the many frameworks with example projects, for pelican I use this https://gitlab.com/pages/pelican

  • fork the project to your namespace
  • go to settings/advanced and rename of the project to one of your choice.
  • go to CI/CD/pipelines and Run Pipeline, this is an automated system to build your project on a shared runner

the build is started when gitlab detect on your project a file named .gitlab-ci.yml with this structure:

image: python:2.7-alpine

pages:
  script:
  - pip install -r requirements.txt
  - pelican -s publishconf.py
  artifacts:
    paths:
    - public/

Basically, this file tells you that: - use the docker image python:2.7-alpine to build the project, because pelican is a python project. if you use another framework, the docker image could be diferent - there is only one job ( could be more ) needed for gitlab pages, and the name must be pages - first install all requirements for the project with pip install - second run pelican -s publishconf.py to generate the static html,css, etc... of your project - and finaly said that it must generate and artifact with all the content of the public folder generated during the build

Now you can go to SETTINGS/Pages to see the url of your gitlab pages domain