How we migrated this blog from WordPress into Hugo
Thanks to the wordpress-to-hugo-exporter tool linked in the Hugo documentations and this guide it was possible to easily convert the files from our old WordPress instance into .md files + media files carefully organized in folders and subfolders compatible with the Hugo static site generator.
We moved the .md files from hugo-export.zip into /content/posts/ and the media files into /statics/posts_img/, adding the new required html templates layouts/posts/list.html and layouts/post/li.html.
For some reason the exporter tool didn’t do everything pitch perfect (maybe neither were our posts in WordPress):
-
the exported
.mdfiles had mixed LF / CR+LF line endings that we fixed with fromdos -
some dates in the front matter was corrupted, luckily they were correct in the filename
-
several indentations in the
<pre>elements and<ul>/<ol>did not come out well -
links to videos were missing.
Additionally we:
-
updated all media paths to match the new
/posts_img/...urls -
fixed several
Html Validatorerrors -
added in
/etc/nginx/sites-enabled/wp.example.com.confthis snippet:server { location ~ / { if ($args ~* "p=xxx") { rewrite .* https://example.com/posts/yyyy-mm-dd-filename/? redirect; } ... }to avoid link rot.
Not as smooth as we hoped but doable!