Inspired by rxqueen’s many cool pages, I finally got around to customizing a few of my tag pages. The good news is it’s easy.
The bad news is it reminded me how annoying my tag organization, or lack of, is and I decided to spend way too much time thinking about it. The more content I add, the more work it is to change tags because Hugo’s tag management is nonexistent. If I decide that Microcontrollers makes a lot more sense as a Category rather than a Tag, I have to edit a bunch of markdown files to make that happen.
I discovered lpar’s hugoutil library which allows tag management from the command line. The library requires you install Go and you will need a usage key for IBM Watson. The github readme does not list the support options so I installed the library to see what they were.
git clone https://github.com/lpar/hugoutil
cd hugoutil
set GO111MODULE=on
go build
C:\Hugo\hugoutil>hugoutil --help
Usage: hugoutil [OPTION]... [FILE]...
--categorize string comma-separated list of categories to add
-h, –help get help
-i, –interactive prompt to choose keywords and category from Watson
--tag string comma-separated list of tags to add
--uncategorize string comma-separated list of categories to remove
--untag string comma-separated list of tags to remove
-v, –verbose output more info about what's going on
-w, –watson add metadata from Watson analysis
-y, –yaml use YAML instead of TOML for writing frontmatter
C:\Hugo\hugoutil>
This isn’t quite what I need. I tried looking for utilities that could help with batch updates of frontmatter. chrisdmacrae’s [Frontmatter Manipulator] (https://github.com/chrisdmacrae/front-matter-manipulator) command-line usage is largely undocumented and users are referred to –help.
C:\>front-matter-manipulator --help
cli.js <command>
Commands:
cli.js convert <file|pattern> <field> Update the value of a field across
multiple files [aliases: u]
cli.js drop <file|pattern> <fields...> Remove the specified fields
[aliases: d]
cli.js fields <file|pattern> Outputs all possible fields for
given files [aliases: f]
cli.js rename <file|pattern> <field> Renames the given field
<replacement> [aliases: r]
cli.js update <file|pattern> <field> Update the value of a field across
<value|regexp> multiple files [aliases: u]
cli.js values <file|pattern> <fields...> Outputs all possible values for
given fields [aliases: v]
Options:
--version Show version number [boolean]
--verbose, -V [boolean] [default: false]
--silent, -S [boolean] [default: false]
--ignore Provide a comma delimited list of files or globs to ignore
[default: "node_modules"]
--help Show help [boolean]
I decided to just fall back on good old fashioned find/replace and maybe learn Regex (ugh) if needed. This actually worked pretty okay, because a lot of the tagging decisions I needed to make were somewhat arbitrary and not based on patterns. I expanded the categories and removed large-volume tags that were essentially acting as categories. I don’t like having single-use tags, so I decided I won’t use a really specific tag, like “Playstation Classic,” unless I have at least 2 items to tag. I dropped around 10 html pages just doing this.
The Single Board Computer category is currently redundant, as I have only ever talked about Orange Pi. I’m actually a lot more interested in microcontrollers now, so I don’t know that I’ll ever explore the other SBC families, but… whatever, I’ll allow it.
I’m not done. Art should be a category, as should Film. But I think I have a better general idea of how to tag and categorize content going forward.