Finally, I need to be able to include a unique <title> tag string for each page. Again, a search through pandoc(1) for variable yields results; using the -V flag enables you to set template variables using -V [KEY]=[val].

A bit more digging in the online docs, however, nets better solution: YAML Metadata blocks—just like jekyll!

So, for each markdown file in my repo, I’ll add a block to the top that looks like this:

---
pagetitle: <pagetitle>
---

$pagetitle$ is the variable I defined in my _layout.html5 that I’m now passing as a template to Pandoc.

Makefile fanciness

Alright, so now that I have the basics of Pandoc down, I need to whip my Makefile into shape.

First thing is I want to convert ALL of my markdown files to html, not just the README.md. So howzabout I add a wildcard target for all the html files? Also, the whole point of this is to make a github pages site, so let’s add that to the Makefile too

Running make at this point should checkout your current git repository to a subdirectory called gh-pages (which should be added to .gitignore on master).

This Makefile first tries to checkout an existing gh-pages branch, otherwise it creates a new orphan branch for gh-pages. After that, we glob the current directory for any file name *.md and run it through pandoc, placing the result in gh-pages/[whatever].html

Niceities

I’m a big fan of pre-processors, so the css/main.css file (which doesn’t actually exist as of yet) should be converted from less. The easiest way to do that: add a package.json with less as a dependency.

{"name":"linkblog","version":"0.0.1","dependencies":{"less":"*"}}

Now running npm install should create a new node_modules directory (which should be added to .gitignore on master). Now we need to add a lessc step to our Makefile.

Now when I update my links repo's markdown files I issue a simple series of commands: make checks-out my gh-pages branch and builds the html and css files, make serve lets me look at the output html at localhost:8000, and, finally, make commit pushes those changes live.

from https://tylercipriani.com/blog/2014/05/13/replace-jekyll-with-pandoc-makefile/

http://github.com/tylercipriani

－－－－－－－－－－－－－－－－－－－－－－－－－－

Building a Website using Pandoc, Markdown, and Static HTML

I’m kind of a nerd about websites. I’m not content to use Dreamweaver, or just write some code. I always want my websites to be a lightweight and optimal as they can be.

When it comes to web publishing, I’ve always been a bit of a minimalist. Over time, I moved this blog from a hosted solution, to a Wordpress install, and then eventually, to Jekyll (that migration process is explained in detail here).

I started off creating my personal site using Jekyll. This was rather a waste, considering that Jekyll’s made for blogs, and that site is really just styled text at its core, with nothing temporal, and no need of fancy tags or pagination. But I still wanted to be able to write in Markdown and style it with CSS afterwards.

So, I got the idea to write everything in markdown, style with CSS, use Pandoc to convert it to HTML, then just drop it onto the server.

Oh, simple!

Actually implementing this was one of those things that’s easy to do once working, but takes forever to get exactly right. The core of it is a single shell script (viewable here, slightly de-identified) which converts the markdown to HTML, then uploads it.

The hardest part of setting all this up was figuring out the syntax of the below command, applied to each folder:

In English, it finds any file which ends with “.md” (a markdown file), then executes the pandoc command, including spcvhead (containing the header info, overarching style info, etc) (B)efore the file , then spcvfoot (A)fter. Then it outputs the rest as .html files. If you want different headers/footers in different parts of the site, just run the command on each folder with a different set of includes.

This gives you folders full of .md.html files, due to a quirk of how Pandoc operates. It then goes through and changes those back to .html files with the below command: