I’m trying to add a description tag to my posts (hosted on Github at https://github.com/krrishsgk/My-Blog ). I’m following the instructions from https://www.mattflor.de/2017/06/04/blog-setup/ , but the solutions provided there aren’t working. Despite making the changes suggested, my website displays the automatic 70 word summary for each post and does not use the text in my ‘description’ tag.
What am I doing wrong? Is there an obvious workaround I am not aware of here?
Thanks!
Are you wanting your site to use description
on the main page which lists blog posts?
What you’ll need to do is override the layout of index.html
.
It’s a 2 step process
- Copy the file
themes/beautifulhugo/layouts/index.html
to layouts/index.html
- Edit this line in your newly created
index.html
so it uses .Params.description
rather than .Params.summary
(you may want to make it so the page falls-back to using .Params.summary
in case the description
isn’t set.
2 Likes
I didn’t know about index.html
, thanks!
It worked. I copied themes/beautifulhugo/layouts/index.html
to layouts/index.html
and used the following code:
{{ if .Description }}
{{ .Description | safeHTML }}
<a href="{{ .Permalink }}" class="post-read-more">[{{ i18n "readMore" }}]</a>
{{ else }}
{{ if .Truncated }}
{{ .Summary }}
<a href="{{ .Permalink }}" class="post-read-more">[{{ i18n "readMore" }}]</a>
{{ else }}
{{ .Content }}`
Thanks a lot for your help!
1 Like