Originally published at: http://www.sitepoint.com/creating-posts-custom-metadata-data-wintersmith/
In the first part of this mini-series I’ve introduced you to Wintersmith, one of the best Node.js-based static site generators in my opinion. I covered how to install and get started with Wintersmith and also discussed some features of Jade, its default templating system.
In this second installment, I’ll teach you how to create posts using the Markdown format, how to set custom Metadata, and also how to generate and deploy your static website.
In the first part of this series, we’ve built our templates with Jade. Now it’s time to create some content for the site. By default, posts are written in Markdown rendered by Marked, though other renders are available as plugins.
Most developers seem to be familiar with Markdown, but if you aren’t, it’s very easy to learn. Many code editors either support it by default or via free extensions. There are many standalone Markdown editors out there, for example I use Mou on OSX and there is MarkdownPad on Windows. This post won’t go into the details of the specifics of Markdown but in case you need a place to start, I suggest you to take a look at this page.
Posts are placed in the
contents/articles folder. Each post is given its own directory which will be its SEO-friendly URL. For instance, our post for the Season 6 episode of Adventure Time! named “Breezy” was placed in a directory named
articles/season-6-breezy. Inside that directory there is our Markdown file for the post named
Each Markdown post can have metadata on top using the YAML format, similar to Jekyll’s “front matter“. No metadata is required but
template is the template that should be used to render the post,
title is the title of the post, and
date is the date it was posted. If
template isn’t specified, the post will not be rendered (which likely isn’t what you want). If
date are unspecified, their values will receive defaults.
We are free to add any other metadata we want to. We’ll discuss this further in the custom metadata section below.
Wintersmith also allows us to specify metadata for posts using the JSON format via a JSON file in the contents directory. For more details on that, check the documentation.
Wintersmith lets us specify where it will end the excerpt within a post. This ensure that the excerpt does not exceed a specific length or ends in a logical spot. In order to specify the end of the excerpt, we have to place the following code within our Markdown post:Continue reading this article on SitePoint