Skip to main content
  1. Main/
  2. Articles/

Website Migration To Gitlab & Hugo

Table of Contents

To reduce maintainability of my website I’m migrating it from an old dokuwiki installation to Hugo generated static HTML on Gitlab Pages.

Migration #

For the migration I used the method of Natenom with a slightly modified script for prepending the Frontmatter to add the date based on the file creation time:

#!/bin/bash

set -e
set -o pipefail

filepath="$1" #path/to/filename.md
file_name="$(basename "$filepath")" #filename.md

md='.txt.md'
title="${file_name%"$md"}" #filname
date="$(date -d @"$(stat --format '%Y' "pages/${filepath%%.md}")" +'%Y-%m-%dT%H:%M:%S%:z')"


TEMPLATE="---
title: $title
date: ${date}
---"

# Remove first line of file (with # Title)
sed -i '1d' "${filepath}"

(
    echo "$TEMPLATE"
    cat "$filepath"
) > temp
mv temp "${filepath%"$md"}.md"
rm "${filepath}"

Afterwards I review every page to fix markdown code and add further Frontmatter. This will take some time so feel free to come back here later.

As I tend to forget the syntax of required Frontmatter I create hooks for pre-commit that add the Frontmatter if fully missing and informs about missing required keys.