Hugo for Microblogs

@ahopi yeah, Amit’s journal is a good example. I reckon he is making a post per each shown date. The list just has no links (save from the small date, which just leads to a page that grouses about ad placement :smile: ), and everything is exposed. You can do that using {{ .Content }}.

As Hugo can not (if I am properly informed) generate files from data it would make sense to work with one .md files for each post so that you can link to each micro post—as here:

It would make sense to use file names according to this scheme: YYYY-MM-DD-HH-MM-SS. You can probably automate generating these files.

All you need in YAML is a “>” for multi-line. I use this for the description in my frontmatter:

description: >
    This is ...
    multi-line text ...
date: ....

But point taken, it might be more bother than it is worth.

And yes, I was thinking of timestamp or date+serial as a slug. Not sure if Hugo can generate a serial number automatically however? Timestamp format is probably easier?

1 Like

If it’s one file per day (or date that you want to blog) you could just use the date I think. I did not know that > syntax. Sweet.

I use this zsh function for making posts in my live blog.

# Function for creating posts

function hugogenpost-live {
if [[ -z $1 ]]; then
    echo "A double-quoted post title is required"
    exit 1

_hytitle=$(echo $1 | tr ' ' '-')
_hytitlelower=$(echo ${_hytitle} | tr "[:upper:]" "[:lower:]")
_hytitlelowerquoted=$(echo \"$_hytitlelower\")
_date=$(date +'%Y-%m-%d')
_datetime=$(date +'%Y-%m-%d %H:%M:%S')

cd ${_workingdir}
${_hugobin} new post/${_hytitle}.md
mv ${_contentdir}/${_hytitle}.md ${_contentdir}/${_contentfile}
# sed -i 's/slug = ""/slug = '"${_hytitlelowerquoted}"'/g' ${_contentdir}/${_contentfile}
# echo ${_hytitlelowerquoted} >> ${_contentdir}/${_contentfile}
$EDITOR ${_contentdir}/${_contentfile}

I have archetypes/ which gets called by the hugo new post in that script:

date = {{ .Date }}
title = "{{ replace .TranslationBaseName "-" " " | title }}"
slug = "{{ .TranslationBaseName | lower }}"
tags = ["x", "y"]
draft = "true"




… but you could have whatever stuff in there you like, adapting the slug etc. For example, just disable tags or leave draft set to false to make less work.

Yeah, I could really do with creating a small VScode plugin for creating new posts for my own blog.

Hmm, actually, now I think about it, I could probably just use the package.json I already have to define a suitable script like yours - VScode can take npm scripts like that and turn them into tasks you can run directly. Except my script will be in PowerShell as I work on Windows :grin:

Really though, I need some tools for setting the file name and selecting categories and tags from my existing sets. More thinking required. Sorry, I’m drifting well off this topic.

1 Like

This is a clumsy but very easy solution (in the case you want to go with one file per post):

VAR="$(date +'%Y-%m-%d-%H-%M-%S')" && hugo new micro/$VAR/ && cd content/micro/$VAR/ && open -a Finder ./ && edit

The script creates a folder with an file and opens the file in the terminal and the folder in Finder (MacOS). So you can easily place images here that can automatically be referenced using the new Page Resources.

A archetype could look like this:

date = 2018-05-21T14:44:45+02:00
slug = "{{ now.Format "15-04-05" }}"

As :hour and :minute are not available in permalinks, I use them as a slug.

By the way: Would it make sense to provide :hour, :minute, :second as permanent vars?

1 Like

Yes. Year, Month, and Day would be the same for multiple posts during the same day. Hours, minutes, and seconds would come in handy if not using file name or title in the slug.

If it helps any, I create a new status post with; the yymmdd I generate with a keystroke shortcut. This gets round the posting more than one status per day, plus enables you to find status posts more easily. The content of the post is then what is displayed

Thanks for that, I will give it a try on a local test site. My skills are not up to the mark for creating layouts and hacking my existing theme, so I will probably clone your entire theme.

Thanks for sharing.

1 Like

One thing to note is that the Hugo archetypes for eg blog posts, status posts etc. are by their very nature tied to the front matter of your content, and the templates are similarly tied to the config.yml values.

This is why I have started to clone the entire site, to make life easier.

To that end, I’ve made a “Hugo Starter Kit” called Indiego:

You can click on the “Deploy to Netlify” button and it will clone the entire site for you to GitHub and deploy it automatically to Netlify.

It’s very bare bones, so the theme would need some styling.

Hope that helps!

I think the idea with micro-blogging is that you don’t want individual pages for posts since they are so tiny. I would think a hash in the URL plus an identifier (i.e., think of tweets’ individual idenitifiers). Don’t get me wrong, individual pages created from single serialized data sources would be a huge win for Hugo, but I don’t think this is the use case :smile:

Totally agreed!

Are you thinking of JavaScript reading a JSON file from the static folder? Or is there way to create hashed URLs from a data file located in data?

(Only advantage of single folders with index files is Hugo’s image processing which can be handy for quick blogging.)

A bit off topic: But this would also be great for event calendars and such.

Here’s another example of a Hugo blog with micro posts:, by Jack Baty.

Here’s the site source.


I’ve just recently imported all of my old Tweets into my Hugo site. Each tweet is its own file, with front matter. These are posts with no titles, but a slug generated from the time of creation, and stored in a directory path that follows /YYYY/mm/dd. I display them in both lists and single content views:


I elected not to show the contents of each item in year or month lists, but only by day.

I further define which items are replies and retweets, versus original tweets. On my home page, I display only those items which are not replies or retweets.

You can see my theme here:

I’m trying to implement indieweb thinking into my site, and Hugo makes it actually quite nice to define post kinds. I also use micropub to create new items and generate my site. This allows me to write new notes on my site, and have them published to Twitter, also.

The indieweb/micropub pieces may be overkill for what you’re trying to do; but thought I’d share how I’m doing microblogging with Hugo.


Do you have a script that grabs the tweets? I’m looking for something like that.

I originally used the Twitter Export feature. Log into Twitter, go to your account settings, then “Your Twitter data” (you may need to confirm your password here). At the bottom of the page is “Download your Twitter data”, which will allow you to download a zip file of your tweets in two different formats: a CSV file and a collection of JSON blobs.

The data here was a little hard for me to work with. I used this data to get the contents of my tweets, but I did end up writing a couple of command line PHP scripts to fetch the content of reposts and replies. I’m happy to share, if these will be of use to you; but they’ll take some cleaning up because they were quick-and-dirty for my immediate needs.

Thanks for that. I will give it a go. I guess ultimately, I’ll be looking for something I can automate but I might be able to do that using Node.JS anyway. Cleaning it up won’t be a problem, I’m used to tidying up data.

I also need to think about how to integrate it into my blog. I’ve been thinking about using a microblog format actually. In Wordpress, you get different post types such as the “aside” which is a micro blog format that appears in the usual timeline. Ideal for integrating your tweets.


Thanks for all the replies and help.

I tried all of the suggestions listed here, but nothing worked to my satisfaction.

I decided to use titles for all of my blog posts, even the “status updates”.

The Hugo generated blog also looks much better with titles.

Thanks to everybody for their inputs, appreciate the help.

1 Like

What if they’ve blocked your account? And then blocked the account you used to report the status of your blocked account? FML. LuL. Seriously though cool stuff are the crawlers eating it up?

I thought about using to generate either a data file to reference, or the HTML pages with configurable statuses on them. Those should fairly easy to incorporate. And if you import on a schedule, you can also delete the posts from the ActivityPub source. Not a bad way to use another system, but have archive abilities.

1 Like