Updating Hugo Templates
This is my personal log detailing how I updated the blog to support the latest version of Hugo.
I rarely write content here. Perhaps I should work on making writing a habit. The blog itself does uses hugo to generate the HTML from Markdown input. This works well. However. Hugo is huge big, super flexible and makes incompatible changes from time to time.
ERROR deprecated: .Site.Author was deprecated in Hugo v0.124.0 and subsequently
removed. Implement taxonomy 'author' or use .Site.Params.Author instead.
As I no expert on Hugo and only use it occasionally, I must admit that such
errors do not help me much. However, it turns out that this is a problem that
can be solver with AI. And in fact ChatGPT provided me with some useful answers
regaring taxonomy and .Site.Params.Author
.
.Site.Author
I fixed an error in config.toml by simply moving data around, because taxonomy is not needed for a single user blog.
- [author]
- author = "Michal Vyskocil"
- profile = "I am software developer and a former field manager with 12+ years of experience, Prague, Czech Republic"
[Params]
+ author = "Michal Vyskocil"
+ profile = "I am software developer and a former field manager with 12+ years of experience, Prague, Czech Republic"
Modifying the config.toml
is only a half of the story. The way the Markdown is rendered is the responsibility
of the used template. This also needs to be updated. This blog uses
(miblog-hestia-pure)[https://codeberg.org/vyskocilm/miblog-hestia-pure], which
is a fork of
https://github.com/diwao/hestia-pure. Therefore with the change above, updating the template was straightforward.
<div class="author__info pure-u-4-5 pure-u-md-7-8">
- {{ if and (.Site.Author.author) (ne .Site.Author.author "") }}
- <h3>{{ .Site.Author.author }}</h3>
+ {{ if and (.Site.Params.author) (ne .Site.Params.author "") }}
+ <h3>{{ .Site.Params.author }}</h3>
{{ else }}
Truncate output
Hugo added a new divider for summaries, which is HTML comment `
`. This broke the index.html and the RSS output. I only realised this once I put the blog online 🤦. As I had no intention of adding the marker to all the articles I had already written, the solution was to truncate each article to 280 characters.
- <p >{{ if .IsPage }}{{ .Summary }}...{{ else }}{{ .Site.Params.description }}{{ end }}</p>
+ <p >{{ if .IsPage }}{{ .Summary | plainify | truncate 280 }}...{{ else }}{{ .Site.Params.description }}{{ end }}</p>
Fixing RSS
Changing the output of RSS was more work. This was because I basically had to fork the default RSS template. And then I had to adapt it to my needs.