Pages and navigation build inconsistently

Hey All,

Hope you can assist me with this issue. New to Hugo, and for the most part it is working great but, I am experience this strange issue where pages and the menu is built inconsistently. So, the site is very small, ~4 pages and I have the pages set-up as follows:

content
---- pages
------ about.md
------ portfolio.md
------ contact.md
index.md

I then run hugo server -D and point the browser at localhost:1313. Now, sometimes the page content loads from index.md as expected, and the menu items are: home - about - portfolio - contact

Other times however the content from index.md is not, and the menu only has the entry for home

With regards to the menu specifically, I have the following in the frontmatter of all the pages:

linktitle: "home"
menu: "main"

What I also see is that, when the content is not loaded on the landing page(index.md), then trying to manually navigate to for example localhost:1313/pages/about results in a 404.

Not sure what is causing this inconsistency. Any idea, suggestions? I would really appreciate any help.

Also, just FYI. I have also tried running hugo server -D --disableFastRender as well as hugo server -D --disableFastRender --gc

Thanks in advance.

Hi there – we’d need to see your site code in order to help you. Please see requesting help.

Just a guess, but this 404 is likely because you don’t have a single page template defined, e.g. layouts/_default/single.html. We would need to see your code to confirm, though.

Sometimes it does work just fine though. As mentioned, when the landing page at localhost:1313 loads the content from index.md, the menu is also correct, and the pages do load. Below is a screenshot of the theme directory:

Sorry, I’m unable to help you based off that screenshot. I’d need to see your actual code. If you can’t do that for some reason, at least provide a link to the theme you’re using.

Hello @schalkneethling, I ran into the same issue sometimes last week. I was able to solve the inconsistency by renaming content/index.md to content/_index.md.

It worked for me, perhaps it could work for you too.

Thanks Weru, will give it a try.

let me know how it goes

Hey zwbetz, I pushed the code here: https://github.com/MechanicalInk/goldratt_pl - Thanks for your help!

So it solved part of the problem it seems i.e. The pages inside the pages folder now loads, and the navigation items are present. But now, the content from _index.md does not load on the landing page.

I thought perhaps I needed both a _index.md and index.md with the second containing the content, but that does not work either. Perhaps there is another way to define what the landing page should be when one load the root of the site i.e. localhost:1313

That index.md has draft: true in the front matter. Make sure all your pages aren’t set to drafts. :slight_smile:

The problem with the home page could be inside config.toml file, here:

baseURL = "http://goldratt.pl/"

You should probably have it like so

baseURL = ""

In retrospect, I think @maiki is right … the problem isn’t necessarily with the baseURL = "http://goldratt.pl/"

This is incorrect. The baseURL is fine, and should be the production URL, as it is – FYI when running hugo server locally, it makes the baseURL as http://localhost:1313/

@schalkneethling @weru – for when to use index.md (leaf) vs _index.md (branch) please see page bundles

Thanks. My understanding is that hugo server -D will build and “deploy” drafts as well?

Thanks zwebtz. Seems that my use of index.md then is correct. The content is still not showing up as the homepage though :frowning: Is there some config I am missing?

In /goldratt_pl/layouts/index.html I added {{ .Content }} and the page content shows. Without that I am not sure how it would, so maybe you were changing that while developing.

Thanks @maiki - I was just looking at that, and it seemed to me like it was actually set-up to do some form of extracts and pagination. Basically like a blogs landing page. Let me try removing all that and replacing it with {{.Content }}

Nope, no go. Changed index.html to be:

{{ partial "header.html" . }}
	<main>
		{{ .Content }}
	</main>
{{ partial "footer.html" . }}

Content is still not showing up on localhost:1313 unfortunately.

Hi,

So to summarize, you have done all of the following and it still does not work for you?

  • Rename content/index.md to content/_index.md
  • Set content/_index.md front matter draft:false OR run hugo server -D
  • Add {{ .Content }} somewhere in layouts/index.html

I cloned your repo just now and did those exact steps and I can see the menu for the 4 pages and the _index.md content when I run hugo server -D.

1 Like