First steps with Wyam

Published on 10 January 2017

I recently watched a video of Chris Heilmann (IMO everyone creating stuff on the web should see it) talking about the state of Internet today.
One part of the talk is about page size and websites being "world widely" accessible, to all connexions. This made me reflect a bit on what I create on a daily basis as well as how I browse and share stuff. Adding this to the fact that I wanted for a while now to make this blog a static one...let's do this!

Why go static and which generator to chose ?

The obvious reason to switch from classical PHP/mySQL blog to static HTML pages is : speed, there are a few other perks to switch. Also, in my case since my blog is a (for the moment ;) ) a one user/writer thing, its ok to not have a user management system. Other reason is that I have been using VS Code quite a lot lately and like (a lot) writing markdown in it, so I was looking for a static content generator that can generator a blog-like website from markdown.

There are a "few" generators out there, but I chose to go with Wyam. I chose it for several reasons : first its in .NET :) and the whole modules and recipes is super neat.

Since it's 2016 and everything is got it, wyam is no exception.
Source : CommitStrip

Going from Wordpress to wyam

I used Jekyll Exporter plugin to convert my HTML based posts to markdown. The exporter works pretty well despite a few quirks : wrong indention on posts breaking the markdown, code blocks mostly broken, etc.

Concerning your content (images and stuff) you have two choices, either you keep the Wordpress folder even after uninstalling, either you copy it to a folder to keep everything nicely in order.

And my custom scripts ?

Wyam being a generator based on templates (more specically on partial views) you can of course add your own scripts. The beauty of it is that you can have all your website parts "out-of-box" and only override a few parts to add your own touch. So compared to a classic CMS, where you would have douzens of php files, you only have a few Rzaor views.

It's easy to add Disqus, google analytics amongst other stuff. You can also add features on site generation by using the pipeline system. Basically, you declare chained C# functions in your config.wyam file. For instance, to generate feeds file (extract of the rss example) :

Pipelines.Add("Blog posts",
	WriteFiles(string.Format("{0}/index.html", @doc.String("RelativeFilePathBase"))),
		// Put the GenerateFeeds module inside a Branch module so that the feed
		// documents don't get added to the set of output documents for this pipeline

More to come...eventually ;)

comments powered by Disqus