It’s all the trend these days to add “reading time” or a word count on your blog posts to indicate how big they are. We often add a word count as it’s super easy to add to your Hugo site (except we don’t on this site - oops!)
Word Count
We can use word counts in our theme template. We’ve shown the likely file below, but might change based on your theme and setup.
The simplest way is to use Hugo’s built-in reading time, like belo:w
1
{{ .ReadingTime }} minutes
Example: 2 minutes
Alternative Way (including seconds):
We can use the word count to produce an estimated reading time for you post. This is based on the assumption that the average person reads about 200-250 words per minute.
1
2
3
4
5
{{ $readTime := mul (div (countwords .Content) 220.0) 60 }}
<p> {{ math.Floor (div $readTime 60) }} minutes
and {{ mod $readTime 60 }} seconds.
</p>
Example: 2 minutes and 47 seconds.
There we have it - a how to on adding word count and reading times to your Hugo blog posts - good luck!
Edd is a PHP and Go developer who enjoys blogging about his experiences, mostly about creating and coding new things he's working on and is a big beliver in open-source and Linux.
Add a 404 Not Found Page
–
In an ideal world, every web page would exist, but sometimes links go to pages that doen’t exist. This is why we make “404 - not found” pages. In Hugo you can do the same. Many of our sites are hosted with Netlify which also support these files - automatically returning the correct http status code for them.
To make yours, you can add a file into your layouts folder.
Using Emoji In Posts & Themes
–
Emojis have been named word of the year and are seen every day in modern culture. We use them every day on our messaging apps, emails and … err blogs!
This post is about how you can enable and use them in both your Hugo themes and, in general, when writing posts.
Using Emojis in Themes To use them within your theme, there’s a built in function which turns text in emojis.
Hide a Page in Hugo
–
Option 1: Draft The simplest way to hide a page when using Hugo is probably to set the post as a draft. This way, you still have the content ready to go for when you need it.
To hide a page by setting it as draft, so our drafts page:
Set Post as Draft Tutorial Option 2: Hide from Posts List You still want the page to be visible, but you don’t want to show it your blog posts list?