This blog has been migrated from Wordpress to Hugo (a static site generator). As with the previous migration (from tumblr to Wordpress) the comments have been lost (although there were only 2), and you’ll need to update your RSS feed link to this.
I have a few reasons for this; one being that I’m already paying for a webhost (so I might as well make use of it), and another being that a website of purely static content is lightweight and fantastically secure.
Migrating from Wordpress
Thankfully Wordpress make it very easy to take a backup of your site as an XML file (you can do this via your admin panel), and this data can then be run through ExitWP to convert the XML into Markdown posts. There’s also a Wordpress to Hugo plugin that you can use if you’re hosting your own Wordpress site (but I couldn’t use this as my site was hosted by Wordpress).
One small caveat of ExitWP is that it’s designed to generate a Jekyll site, and while Jekyll and Hugo have very similar layouts, some of the frontmatter in the posts needed to be updated to work with Hugo (although this may be a side effect of the Wordpress XML rather than the fault of ExitWP).
--- author: jdale88 comments: true date: 2013-10-01 20:59:12+00:00 layout: post link: https://jdale88.wordpress.com/2013/10/01/c-an-exercise-in-optimisation-1-immutablestring/ slug: c-an-exercise-in-optimisation-1-immutablestring title: '[C++] An exercise in optimisation #1 - ImmutableString' wordpress_id: 80 categories: - c++ - game development - tutorials ---
--- date: 2013-10-01 20:59:12+00:00 slug: c-an-exercise-in-optimisation-1-immutablestring title: '[C++] An exercise in optimisation #1 - ImmutableString' tags: - c++ - game development - tutorials ---
The biggest issue was the
layout tag, as that caused the theme I’m using to render blog posts with the wrong template. I also needed to rename
tags for a similar reason, but the rest of the tags that I removed were just superfluous.
Setting up Hugo
Setting up Hugo is really easy, just grab the release for your platform, and then follow the quickstart guide to create a barebones Hugo site. Once you have your barebones site, you can copy the result of ExitWP into it, taking note of some minor pathing changes; the
_posts folder should be
post, and any Wordpress pages should be in the root (eg,
about/index.md would just be
In order to actually render your content, you’ll also need to create or download a theme for Hugo to use. I went with Blackburn as a base, stripped out some things that I didn’t need, tweaked the layout to suit my needs, and upgraded its libraries to the latest versions.
If you have code in your posts then you’ll also have fix-up the syntax used for syntax highlighting, as ExitWP produces syntax like this:
[sourcecode language="cpp"] // ... [/sourcecode]
And Hugo needs syntax like this (the syntax highlighting for this site is provided client side using highlight.js):
```cpp // ... `` `
Note: The space in the closing block shouldn’t be there, but it needs to be for this example as the Markdown parser can’t handle nested code blocks.
I find that Markdown handles source code really well, and it’s actually one of the reasons why I prefer writing my blog posts in Markdown. I’ve always had issues with the way other blogs would handle source code, as you’d often have to HTML-escape it (which the Markdown parser does for you) to avoid it being interpreted as nested HTML.
Content iteration in Hugo is fantastic. It has an internal webserver that will render a draft of your site and watch the source files for changes, so as soon as you change any of your site source files (including adding new files), the site is re-rendered and your webbrowser is automatically refreshed. It’s mostly flawless, although I’ve found that editing the
config.toml file for your site often seems to break the renderer until you restart the server.
Obviously the downside to a static site is that you have to version it yourself, but I don’t really see that as much of a downside. Since my site source is… well, source, it just goes into source control (for this site I use Mercurial with a Bitbucket repo), and I commit new versions of the site as I make changes. That, to me, is far better than a database of content that I don’t have much control over.comments powered by Disqus