Scott Watermasysk
Adding Paging Titles for Short Micro.blog Posts
I noticed posts without titles do not have proper HTML Title tags on my new Micro.blog.
Even as I type this, I kind of get it. How do you have a title without a title? 🤔
Many services rely on a title element when building links, and seeing "ScottW's Blog" (or whatever I eventually name this thing) looks silly.
I checked the source for a couple other Micro.blog templates and found none of them did anything special to handle the missing title. Most looked something like this:
<title>{{ if not .IsHome }}{{ .Title }} - {{ end }}{{ site.Title }}</title>
After some trial and error, I noticed the .Summary
value for the default meta description tag and decided to use that. This is the first 'code' I have written in Hugo, so it might need some more tweaking in the future:
<title>
{{ if .IsHome }}
Home
{{ else if .Title }}
{{ .Title }}
{{ else}}
{{ .Summary }}}
{{ end }}
- {{ .Site.Title }}
</title>