Last Updated: February 25, 2016
· jeremymorgan

Creating Generic OctoPress Headers

I saw another question on the Octopress GitHub list about <a href="">importing existing markdown files</a> and it turned out he needed some header info added to the pages, and those are usually added by Octopress. He had a program that converted all his .html files to markdown, and had to add them by hand.

I wrote this quick Ruby script to do it, and now I'm sharing it everywhere I can in hopes that it will help others with this same problem:

#!/usr/bin/ruby -w
# Header adder
# adds some generic headers to your Markdown files for Octopress
# use/branch/distribute as you see fit

Dir["*.markdown"].each { |ourfile|

content =
newcontent = "---
layout: post
title: \"TITLE\"
date: 2012-10-23 01:38
comments: true
author: Your Name
- Your Category
permalink: \/permalink
---\n\n" + content, 'r+') { |file| file.write(newcontent) }

I hope this helps others! Create this file and run it in your src folder and it will add a generic header to each markdown file, you will still have to fill in the information for each page however.

You can also fork this from github: <a href=""></a>