Structure hugo blog posts with hextra theme
10 March 2025
By default hextra will create one big list of blog posts. You can structure you posts in subfolders and add _index.md
files to control this behaviour.
Example configuration
Blog post folder
content/posts/_index.md
---
title: Blog
weight: 1
draft: false
sidebar:
open: false
cascade:
type: blog
---
Subfolders in posts
I structure posts with subfolders for year and month:
- _index.md
- _index.md
- _index.md
- _index.md
- _index.md
Group via _index.md file
Then I create an _index.md
file in every subfolder that I want to group. At the moment I only create this file for previous months and years so the most recent month/year will appear directly.
Previous months
content/posts/2025/02/_index.md
---
title: February 2025
draft: false
sidebar:
open: false
# type: blog
description: All posts in February 2025
---
Previous years
content/posts/2024/_index.md
---
title: 2024
draft: false
sidebar:
open: false
# type: blog
description: All posts in 2024
---
Create post urls without year/month
Use post slugs and adjust permalinks configuration to get post urls without year and month(link to blog post)
I use slugs only permalinks to avoid having year and month in a post page url.
Configure previous and next post links
- by default hugo hextra will not show links to the next post at the bottom of the page when its the last/first post of a subfolder
- but you can set the links manually in the frontmatter of a post
--- prev: '<next-newer-post-slug>' next: '<previous-older-post-slug' ---
- for some reason these fields are reversed (
prev
link must be next post and vice versa)- there seems to be some discussion about this
- for some reason these fields are reversed (
Additional resources
Related content
Learn how to configure the code highlighting chroma theme in hugo hextra.
I was not happy with my hugo theme. This article describes how to switch to a different theme called hextra.
Umami is similar to Google Analytics. But it is better. Learn how to setup and use it with your hugo static website.
You can add interactive diagrams to your hugo page via plotly.