I have been building/maintaining a website with Hugo for ~3 years now, and I have just run into a problem that is causing the build to produce no pages.
It was working fine until I began experimenting with the ‘branch/leaf’ pages model. The basic premise of the problem is:
If I name my homepage “content/_index.md” the index page is generated, but the page scoped scratch pad does not seem to work. Which is what I am using to fill meta tags in the head, such as og:image, and video, and some JSON+LD structured data nodes. However by naming the homepage this “_index.md”, all of my other pages are not generated; the folder structure exists but there are no other HTML pages anywhere!
If I name my homepage “content/index.md” the index page is generated, but no a single other page is generated. The folders that contain some static content related to leaf pages exist with the image files. But not a single HTML file besides the root index.html is generated.
Any help or explantion would be really appreciated. This is perplexing the heck out of me and becomes a bit of a show stopper for continuing to develop this site.
I am going to be removing all the branch/page bundle formatting and return to the original structure design but any help advice would really help.
Having content/index.md means that the home page is a leaf bundle, which then means that all other content become Page Resources. This then means that page-type resources, such as your other .md files, are accessible only as Page Resources. They are not processed into html pages (ie they have no Permalink).
I also notice that you have content/blog/index.md. Similarly, this means that content/blog/ becomes a leaf bundle, and post-x become page resources. Renaming this to content/blog/_index.mdshould then generate /blog/post-1/ etc.
I’m not sure what you mean here:
If you have your code in a repo somewhere, it would make it easier to see what is going on.
@pointyfar thanks for the explanation. Saved me a ton of headache.
As for the second part, I mean when I do .Page.Scratch.Add in a short code from the content and ‘.Page.Scratch.Get’ from the template in the header doesn’t seem to work on the index page unless it is name ‘index.md’. If name is _index.md then the Scratchpad always seems nil, but when I name it otherwise it works fine. This functionality works fine on my other pages when it’s named _index.md, just not on the index page.
Hey thanks again, and for the quick reply. Unfortunately its a business site so showing the actual code is a no-go. I could produce a minimal example, but it would take more time then I think it’ll take find a fix.
So to run through again:
In my content I am using a shortcode that adds an image, and adds a value to the scratch pad for the page. And some other values that are used in the head for open graph tags.
In my _index.md page the scratchpad is nil when the head is rendered.
In my ‘about-us/index.md’ page the scratchpad has the correct values.
When I change the homepage to index.md the scratchpad is filled correctly, but the rest of the pages are not generated.
I am going to reformat my folder structure to remove any branch/leaf page types, which hopefully will fix my issue.
Is there any other way to name the homepage such that it will be accessible from the empty url website.com/?
I’m personally out of ideas, sorry; you may want to open a new topic with the .Scratch issue (ideally with a minimal example), as others might not see the question this far down the discussion.