HomeThe Classics

Was Making abbr.html Necessary?

Published:

I was working on a post reflecting on my old personal sites and I discovered a file called abbr.html in the folder containing the archives of my old site. The code goes like this:

{{ $abbr := .Get 0 }}
{{ if not (isset (.Scratch.Get "abbrs")) }}
    {{ .Scratch.Set "abbrs" slice }}
{{ end }}
{{ if not in (.Scratch.Get "abbrs") $abbr }}
    {{ $abbrs := (.Scratch.Get "abbrs") }}
    {{ .Scratch.Set "abbrs" (append $abbr $abbrs) }}
    <abbr title="{{ .Get 1 }}">{{ $abbr }}</abbr>
{{ else }}
    <abbr>{{ $abbr }}</abbr>
{{ end }}

It’s a shortcode for Hugo and it seems to render the <abbr> element. It checks if an acronym has been defined in the page’s temporary data store (.Scratch) and if not it renders it along with its title attribute, otherwise it just renders the acronym itself.

Reading that MDN (Mozilla Developer Network) page, this feels like overkill since you can just write the acronym’s meaning manually without the <abbr> element. I guess the reason is if you want to style acroyms differently or if you can’t explaining inline somehow.

I’m just confused as to why I put it in the folder of old websites in the first place…