Posts not listed on home page in production build

I’m about to deploy my new hugo site. I have two blog posts ready to go. When I run hugo on my local computer in dev mode, both posts are listed on the home page. However, when I ran

hugo server -e production

to test what it would look like in production, hugo has created a home page with only a link to one of the two blog posts. I’m not sure if this is a theme level issue or a hugo issue.

I’m very limited in my choice of themes (I believe) because I couldn’t get CGO on my windows computer to build the themes that require it.

Any suggestions about how to get all blog posts listed on the home page?

Incidentially, I am using the mini theme.

Is draft set to true on either of the posts? Is one of the dates in the future?

https://gohugo.io/troubleshooting/faq/#why-is-a-given-page-not-published

If you need additional assistance, please post a link to the public repository for your project.

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.

Thank you for your response. Draft is set to ‘false’ on both posts.

I pushed my site to github for you to take a look. Thank you

MikeMitchellWebDev/hugoblog (github.com)

image

That says draft = true.


that says draft = false

can you explain the discrepancy? I’m looking in the content/posts folder

What you have locally is irrelevant. Look at the content of your repository:

https://github.com/MikeMitchellWebDev/hugoblog/blob/main/content/posts/master-plan-michael-healey.md

I’m guessing you haven’t committed and/or pushed changes.

I only pushed that code to show you the blog. 1 hour ago it didn’t exist on github.com. I have the site on my local computer and never intended to push it to github until this problem arose.

to further illustrate, here’s a screenshot of the generated html of the blog post in the public folder, which I thought hugo only generated if draft was set to false.

I’m not sure how to make this any clearer. The draft flag does exactly what it is supposed to do, and its behavior in this context has not changed in a decade.

The only reason you might see content in public that is marked draft in your content directory is if you toggled the value and you didn’t clear your public directory.
https://gohugo.io/getting-started/usage/#build-your-site

I deleted the public directory and rebuilt. It’s working now. Thank you for your help.

If your production site uses the “public” directory that you create locally, you should always clear the public directory before building to remove draft, expired, and deleted content.

If your site or theme has a static directory, even if it is empty, you can use the --cleanDestinationDir command line flag when building your site.

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