This article assumes you know about…
Go Templates,[2]
the slice data structure,
and the set-theoretic intersection (∩) operator:
In a nutshell, the syntax of
Hugo’s intersect
function
is this:
intersect SLICE1 SLICE2
Or, in a pipeline, this:
SLICE2 | intersect SLICE1
💡 | The order of
the
slice that
results
from this
intersection
is the order of
|
To learn more about this function, see…
and the example below.
In Infinite Ink’s Hugo project, I tag an article by including something like this in the front matter of the source of the article:
tags: - content - gohugo - mathematics - tech - yaml - secret
Note that
the
value of
this
tags
[3]
key
is
a
slice.
To hide Infinite Ink’s secret[4] tags from the public, I do these two steps.
In
the
Hugo
project’s
config.yaml
,[5]
I
create
the following
user-defined
listablePortals
site-wide parameter.
params: listablePortals: - activism-hacktivism - asciidoc - backup-sync - business-economics-money - cheatsheet - cli - elsewhere - emoji - forked - git - git-bash - gohugo - golang - intellij - iusethis - joplin - longform - markdown - mastodon - mathematics - mathjax - messaging - meta - nix-nux - privacy-security - productivity - qutebrowser - tech - tumblelog - twitter - unicode - utf-8 - vim - vscode - webdev - windows - words - zeitgeist
Note that
the value of
this
listablePortals
key
is a
slice.
In the relevant Hugo layout file, I include this Go Template code:
{{ $tags := .Params.tags }}
{{ $portals := intersect site.Params.listablePortals $tags }}
{{ range $portals }}
<a href="/portal/{{- . -}}/">#{{- . -}}</a> 
{{ end }}
For this article, this intersection code produces this:
More examples of results of this intersection code is in each tumblelogged item in the Elsewhere Links News section of Infinite Ink’s News.
For more about Hugo, see Infinite Ink’s…
Hugo Shortcodes: Including Go Templates in Hugo Content Files
A Way to Compare Hugo’s Markup Languages (featuring inline footnotes)📊
Hugo’s Markup Languages: AsciiDoc, HTML, Markdown,
Hugo’s .RenderString
Method (featuring AsciiDoc admonitions in Markdown and Go HTML)
Configuring Security in Hugo (featuring settings needed to use Asciidoctor and Pandoc)🔒
TGIH: Themeless & Gitless Introduction to the Hugo SSG (a Hugo tutorial)
🔗 Linkified Section Headings in Hugo-Generated Web Pages (featuring Markdown and AsciiDoc examples)
Variable and Parameter Names in Hugo (featuring camelCase🐫 and snake_case🐍)
Transforming Text with Hugo (featuring plainify
, htmlUnescape
, and more)
tags
front-matter key is one of Hugo’s default taxonomies. To learn about this, see gohugo.io/content-management/taxonomies/ and www.ii.com/hugo-tutorial/#_taxonomies.yaml
, is one that has not been turned into a portal. Most secret tags will eventually be portalized.🤞@nm@mathstodon.xyz
or
#InfiniteInk
in it.