Migrating from Hugo to MediaWiki
From CaveLab
The platform hopping continues! As you may have noticed — I have switched from Hugo to MediaWiki. One being a static site generator, the other is the software that powers Wikipedia.
Why change?
- Editing is easy with Mediawiki, very easy. Simply go to a page and click edit, it can be done anywhere. With Hugo there are more steps involved; edit markdown file, commit and deploy.
- A wiki has full revision history, which I find quite useful. Committing your Hugo content files to git also gives you that; but what to do with a couple of gigabytes of images? Do you commit those?
- MediaWiki is massive, popular and well maintained. It's easy to find resources online. This is also true for Hugo, so I guess it's a draw here.
- Content management in MediaWiki is awesome! It keeps track of how pages are linked, and here images and media files are used. Wanted pages/categories/files are really useful.
- Internal linking with MediaWiki is very easy and easy to maintain.
- MediaWiki handles redirects well, and it's easy. Moving pages leaves a redirect, and double redirects are automatically handled.
- Thumbnail creation, photo galleries, lightboxes — it all works very well in MediaWiki.
- Using a bot for content management in MediaWiki is pretty sweet!
- Templates, page inclusion and preloads makes it quick and easy to create new pages.
- I feel a wiki is a better platform for publishing early and improve later; I like to get information, images, videos, etc published as soon as I have something. I can always improve it later. With a blog the number of draft posts kept growing...
How did you migrate?
That was actually easier than I had anticipated... I converted markdown to MediaWiki syntax using PanDoc.
find content -name "*.md" -exec pandoc -w mediawiki {} -o {}.wiki \;
I manually copy and pasted the content of the files into the web form, and validated the syntax. After all pages were created, I was left with a wanted files list of about 300 items. I put this into a text file and used a combination of find
and Pywikibot to automatically locate and upload them.
while read p; do
find -L ~/Photos/ -iname "$p" -print -quit >> found_files
done <wanted_files
while read p; do
cd ~/dev/pywikibot/core_stable/
pipenv run python3 pwb.py upload -keep -noverify $p "Migration from Hugo blog" < /dev/tty
done <found_files
That was mostly it, I did have to tweak the pages a bit. But that was minor stuff really.