Over the last week, I have been working on incorporating microblogging – short, untitled posts – into my new Ghost blog. This is some short documentation on how it’s currently set up.

First, I label each micropost with an internal tag, #note. This can be used to remove the title field of microposts from the post list and individual post pages, create a separate collection, and customize the RSS feed.

Title and permalink

I am using the Attila theme. In this theme, we need to modify /partials/loop.hbs and /post.hbs to do two things with microposts: 1) not display the title and 2) use the date as the permalink.

Here is the code to not show the title:

{{^has tag="#note"}}
    <h1 class="post-title">{{{title}}}</h1>

And here is the code for using the date as the permalink:

{{#has tag="#note"}}
    <a href="{{url}}">{{ date published_at format = "HH:mm"}} | {{date published_at format = "DD MMM YYYY"}}</a>
    <a href="{{url}}">{{date published_at format="DD MMM YYYY"}}</a>


You might prefer your microposts to be separate from longer posts. In this case, modify routes.yaml according to the official documentation.

It might look something like this:

    permalink: /{slug}/
    template: index
    filter: tag:-hash-note
    permalink: /notes/{slug}
    template: index
    filter: tag:hash-note

RSS feed

For the time being, I have chosen to keep all my posts in one feed. Here’s the official documentation on Custom RSS.

My routes.yaml includes:

    template: custom-rss
    content_type: text/xml

And my custom-rss.hbs template looks like this:

<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
        <title><![CDATA[ {{@blog.title}} ]]></title>
        <description><![CDATA[ {{@blog.description}} ]]></description>
        <lastBuildDate>{{date format="ddd, DD MMM YYYY HH:mm:ss ZZ"}}</lastBuildDate>
        <atom:link href="{{@blog.url}}" rel="self" type="application/rss+xml"/>

        {{#get "posts" limit="all" include="tags"}}
            {{#foreach posts}}
                    {{^has tag="#note"}}
                    <title><![CDATA[ {{title}} ]]></title>
                    <link>{{url absolute="true"}}</link>
                    <guid isPermalink="false">{{id}}</guid>
                    <pubDate>{{date format="ddd, DD MMM YYYY HH:mm ZZ"}}</pubDate>
                    <content:encoded><![CDATA[ {{content}} ]]></content:encoded>

When I was customizing RSS, there were two simple mistakes that took me a while to realize. One, YAML syntax is particular – you must put /rss/: on the line immediately under routes:, and you must use two-space indentation correctly. Two, the template must be in the correct folder.

If you want to learn more about microblogging, start here.