Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at

hpr3823 :: Gitlab Pages for website hosting

Three examples of using Gitlab's CICD to generate a website.

<< First, < Previous, , Latest >>

Hosted by norrist on 2023-03-29 is flagged as Clean and is released under a CC-BY-SA license.
static website, gitlab pages, docker, mysql, cicd, . 2.
The show is available on the Internet Archive at:

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:26:00


How it works

GitLab always deploys your website from a specific folder called public in your repository. To deploy your site, GitLab uses its built-in tool called GitLab CI/CD to build your site and publish it to the GitLab Pages server. The sequence of scripts that GitLab CI/CD runs to accomplish this task is created from a file named .gitlab-ci.yml, which you can create and modify. A specific job called pages in the configuration file makes GitLab aware that you're deploying a GitLab Pages website.

Overview of Steps

  • The end state has to be a directory named public that contains the site contents
  • Optionally, run a build process in a container to create the contents of the public directory
  • There has to be a pages declaration in .gitlab-ci.yml

Example 1

simple demo

  • Create the Git repo and site content
  • Go to gitlab and create new Gitlab repo
  • Clone it to your workstation
  • Add public folder with site files
  • add .gitlab-ci.yml
  • Commit and push
git clone
cd simple_pages_demo/
mkdir public
echo "Hello World" > public/index.html
git add public/
vim  .gitlab-ci.yml
git add .gitlab-ci.yml
git commit -am "new page"
git push


  stage: deploy
    - echo
      - public

Pages settings

  • Menu on left, Settings, Pages
  • Your pages are served under:

Example 2

  • Combine my HPR show notes into a single page
  • Custom Domain
    • Verified with TXT record


image: "debian"
    - apt-get update
    - apt-get install -y  pandoc

- build
  stage: build
    - bash
      - public
set -euo pipefail
mkdir -pv public
for MD in $(ls *md)
    # echo "---"
    # echo
    # echo "#" $MD
    echo "---"
    cat $MD
done    \
|pandoc \
-H markdown.header \
-B body.header \
--toc \
--toc-depth=1 \
-f gfm \
-t html \
-o public/index.html

Example 3

HPR static

  • Build the new HPR static site


  - mariadb

  stage: .pre
  image: mysql
  - echo "SELECT 'OK';" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mariadb "$MYSQL_DATABASE"

  image: debian
      - apt update
      - apt -y install libgetopt-complete-perl libmemory-usage-perl libconfig-std-perl libtemplate-perl libtemplate-plugin-dbi-perl libclass-dbi-perl libtie-dbi-perl libdbd-mysql-perl  libdate-calc-perl
      - apt -y install curl mariadb-client git
      - curl -o hpr.sql
      - mysql --user=root --host=mariadb "$MYSQL_DATABASE" --password="$MYSQL_ROOT_PASSWORD"  < hpr.sql

  stage: build
    - git clone
    - cd hpr_generator
    - git apply ../mysql_settings.patch
    - grep "database\|user\|driver\|password" site.cfg
    - ./site-generator --all
    - mv -v public_html ../public

      - public

site.cfg Patch

diff --git a/site.cfg b/site.cfg
index aefadb2..0243d27 100644
--- a/site.cfg
+++ b/site.cfg
@@ -8,10 +8,10 @@
 #user:        (not used - leave blank)
 #password:    (not used - leave blank)
 # Configuration settings for MySQL
-#database: mysql
-#driver: dbi:mysql:database=hpr_hpr:hostname=localhost
-#user: hpr-generator  (Suggested user with read-only privileges)
-#password: *********  (Password for user)
+database: mysql
+driver: dbi:mysql:database=hpr_hpr:hostname=mariadb
+user: root
+password: mysql

 # Configure the location of the templates and the generated HTML
@@ -25,7 +25,7 @@ output_path: ./public_html
 content: page.tpl.html
 #baseurl: OPTIONAL [i.e. file://<full path to local website directory>]
-baseurl: file:///home/roan/Development/hpr/website/hpr_generator/public_html/

 # Configure the navigation menu and the content templates for each page

Other Example Projects

Common Frustrations

  • Waiting on builds during debugging.
  • Having to push to CICD instead of running local

HPR Generator -

Gitlab Example Repo Gitlab pages URL


Subscribe to the comments RSS feed.

Comment #1 posted on 2023-04-01 11:32:11 by rho`n

Congfiguring HPR site generator

Great show norrist! It did make me revisit the site.cfg file for the generator. I thought I had a section to configure where the templates folder and output folder is, and there is.

If you look for: ``` # Configure the location of the templates and the generated HTML [app_paths] templates_path: ./templates output_path: ./public_html ``` Would save you the copy step in your CI steps :)

Comment #2 posted on 2024-02-18 11:37:14 by elmussol


I loved this episode, informative, well explained with great shownotes.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
What is the HOST_ID for the host of this show?
What does HPR mean to you?