I'm getting frustrated with Hugo. Too much magic to understand what is happening

I thought I had it figured out, but I still notice some problems with my website. Even my development site is wrong. First of all, how is the home page generated? I had no _index.md file in my root, yet it was creating a list of posts that I had made. So I created an _index.md under my content folder and now my home page shows that plus the list of posts. But here’s the kicker. The posts are only as recent as January 16th. No new post is showing up on my home page, yet they show up in my Posts section.

This is my first issue. If someone could explain how the home page gets created and how these posts get added, maybe I can resolve this issue before I move on to the next ones.

I’m trying to create a sports website. My content folder is quite simple. I have the _index.md file and four other folders, each with their own _index.md file except for the posts folder.

My Hugo.toml file looks like this:

baseURL = 'https://www.jeffselfsports.com/'
languageCode = 'en-us'
title = 'Jeff Self Sports Analytics'
theme = 'beautifulhugo'


    name = 'Blog'
    pageRef = '/posts/'
    weight = 1

    name = 'Baseball'
    pageRef = '/baseball/'
    weight = 2
    name = 'Basketball'
    pageRef = '/basketball/'
    weight = 3

    name = 'Football'
    pageRef = '/football/'
    weight = 4

I was using the Ananke theme but I’ve switched to the beautifulhugo theme. I’ve done no modifications to the theme at all. So if I can figure out the home page issue, maybe I can start to figure out a few others.

This is the home page template:

Regardless of whether there is a backing file (i.e., _index.md), pages are automatically generated for:

  • home
  • top level sections
  • taxonomies
  • terms

Thanks for providing the location.

But do you have any idea why my listing of posts has stopped? Is there any way to clear it out? I’m thinking I might have created new postings under content and not under the posts subfolder. But then I deleted the files or moved them. But what would cause Hugo to still think there are posts while not including the more recent posts?

I have no idea without access to your project repository.

See Requesting Help.

Let us see your code

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.



I suspect it is private.

That it was.

OK, which content types do you want listed on the home page? You currently have 4 content types: baseball, basketball, football, and posts.

If you only want posts, put this in your site config:

mainSections = ['posts']

If you want posts and baseball:

mainSections = ['posts','baseball']

That’s what this line in the template is looking for:

The file content/posts/my-baseball-changes.md does not appear because draft is true in front matter.

Appreciate all the help! That fixed it!

Hugo in Action by Atishay Jain is a hands-on book you can build a website with and learn at least the basic concepts of Hugo, or dive deeper if you want.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.