How to override blog template generator (article.tt) in Middleman Blog Gem?

359 Views Asked by At

The middleman blog gem creates new articles based on lib/middleman-blog/commands/article.tt Current format is is;

---
title: <%= @title %>
date: <%= @date.strftime('%F %R %Z') %>
tags:
---

What is the best way to override that if I wanted default front matter to be something else like;

---
layout: blog
author: Dave
---

(Other than opening the gem and changing it there.)

2

There are 2 best solutions below

0
On BEST ANSWER

Solved it by adding blog.new_article_template to blog settings in config.rb like so

activate :blog do |blog|
  blog.prefix = 'blog' 
  blog.new_article_template = 'source/blog/template.erb'
end
0
On

There is no built-in way to override that.

But probably you could find where in Middleman Blog code that file is invoked and override that method from config.rb, having it pointing at a different template file.