I used to use Blogger, but recently moved over to Hugo, so I could use Markdown for writing posts. This is much easier for me, in terms of writing notes, formatting code, embedding links and images, etc.
But this process does not have much built-in support for drafting and publishing posts, so there is some extra work needed, which I used to get out-of-the-box with Blogger.
Here is the process:
In Hugo, I have the following post.md
archetype:
---
title: "{{ getenv "POST_TITLE" }}"
date: {{ .Date }}
lastmod: {{ .Date }}
draft: true
toc: false
tags: [tbc]
summary: "tbc"
---
tbc
The title is loaded from the POST_TITLE
environment variable (more about that below).
By default, documents created from this archetype are set to draft
. These draft
documents are not included in the public site. I have to edit the headers to change a document from draft
to public.
To create a new document I have a very basic Python script. This allows me to type in a new title for the new post. It assigns the title string to the POST_TITLE
environment variable, generates a file name from the title, and then creates a new Markdown document.
Finally, it opens the document in Atom.
|
|
In Atom, I hit Ctrl-Shift-M
to activate the Markdown Preview side-by-side view of the document. For some reason I have to do this twice (or just start typing something) as I always get an error message, the first time I try to open the Markdown Preview window:
Previewing Markdown failed - html.trim is not a function
I think there is some cross-package interference happening here…
My site includes a custom search page. To support this, I generate two JSON files by scanning the Markdown files after each content change (i.e. an edited page or any new page).
I use a small Java program for this.
The two files are saved into the Hugo static
folder. They are accessed by the search function to show matching pages based on the provided search text. Stop-words are removed from the indexing process.
This is a fairly crude approach, but results in fast - if basic - searching.
The two JSON files are shown below.
One entry per page:
|
|
An array of page IDs for each indexed word:
|
|
Changes to content are pushed to a GitHub repository.
I then use Render as my static site host. My Render account has a watcher to detect changes to the GitHub repository, which then triggers a rebuild of the Hugo site. For managing one static site, Render does not charge me any fee.
The overall process has more steps than the old Blogger approach, but I find the ability to use Markdown is worth those extra steps.