Parallel building challenges

Unlike Github, Gitlab considers Hugo blogs first class citizens and does not impose any restrictions on repo naming.

I had 3 challenges to overcome related to co-existence of GH and GL versions:

  1. I need to use same repo for both GH and GL
  2. the submodule link for public does not work on GL
  3. the site root is different - I have no custom domain forward for GitLab

Using same repo

To separate the GH and GL, I have added 2 remotes to repo and special branch gitlab-pages.

So the local repo looks like this:

➜ git:(master) ✗ git remote -v -v
github (fetch)
github (push)
origin (fetch)
origin (push)

The branch gitlab-pages is “superset” of master. This means that I am always merging master => gitlab-pages but never the other way around.

The consequence is that GL version can have more posts than GH and as GL version is private, it is OK.

Publishing process and public

GL allows simple pipeline that generates the site into public folder. The submodule does not need to exist. Actually, it cannot exists, as it would be breaking the build.

Here is the file .gitlab-ci.yml

image: monachus/hugo


  - mkdir -p public
  - hugo --baseURL
    - public
  - gitlab-pages

The pipeline runs ONLY for gitlab-pages branch and resulting pages can be seen at (this is currently private).

Removing the submodules

I used this as opportunity to clean the unused themes from the blog:

# Step 1 - deinit repos

➜ git:(gitlab-pages) ✗ git submodule deinit themes/ananke
Cleared directory 'themes/ananke'
Submodule 'themes/ananke' ( unregistered for path 'themes/ananke'
➜ git:(gitlab-pages) ✗ git submodule deinit themes/hugo-coder
Cleared directory 'themes/hugo-coder'
Submodule 'themes/hugo-coder' ( unregistered for path 'themes/hugo-coder'
➜ git:(gitlab-pages) ✗ git submodule deinit public
Cleared directory 'public'
Submodule 'public' ( unregistered for path 'public'

# Step 2 - delete the files

➜ git:(gitlab-pages) ✗ rm -rf themes/ananke
➜ git:(gitlab-pages) ✗ rm -rf themes/hugo-coder
➜ git:(gitlab-pages) rm -rf public

# Step 3 - delete the parts of `.gitmodules`


➜ git:(gitlab-pages) ✗ cat .gitmodules
[submodule "themes/ananke"]
    path = themes/ananke
    url =
[submodule "themes/hugo-coder"]
    path = themes/hugo-coder
    url =
[submodule "themes/even"]
    path = themes/even
    url =
[submodule "public"]
    path = public
    url =


➜ git:(master) ✗ cat .gitmodules
[submodule "themes/even"]
    path = themes/even
    url =

# Step 4 

git add -u
git commit 
git push


  • publishing to GH works as before => run ‘./’
  • publishing to GL happens on any push to branch ‘gitlab-pages’
  • getting changes from GH to GL:
# Sync up master on both
git checkout master
git pull github
git push origin master

# Get the gitlab-pages
git checkout gitlab-pages
git pull origin
git merge master
git push origin gitlab-pages
# optionally, may want to push to GH as well
git push github gitlab-pages