I have a website that I had not maintained for a while. It was made with hugo 0.20, back in 2017, but now I would like to port it to the current release, 0.58.3.
After generating the files, I noticed that almost everything is more or less the same, but the home page is definitely broken: the content of the homepage is there, but it is as if the layout is not used anymore.
The source code of the website is here, if you want to inspect it or try compilation by yourself: https://github.com/pigreco-luogoideale/hugo-site
It is likely that this problem is due to the page bundles introduced in 0.32, but I am unable to understand what is causing the issue.
As you can see, I have no themes installed and I am using just the
layouts directory. In there, I have
index.html that should use partial templates for header and footer, and the
content/_index.html should use that layout.
I would like to understand how to fix it and why the issue is arising: in my
content directory I have no other files besides markdown and html page files, so I think bundles should not even be considered.
Thanks and best regards!
I previously found this issue, but I am unable to see if that is my case.
Try putting blank front matter at the start of
/content/_index.html (i.e. two lines of
At the moment, hugo is thinking it should just dump the content of
/content/_index.html as your site’s
/index.html rather than using the layout defined in
I’ve cloned your site and done this, and your front page now looks much better.
Thanks a lot, the problem seems indeed solved!
Now, two follow up questions for you
- how do you know that hugo was ignoring the layout? (I mean, besides observation :D)
- is there a “explaining” or “tracing” mode, that shows what hugo is searching/taking into consideration when compiling pages?
Thanks a lot!
The troubleshooting process was
- Looked at the code of your repository.
- I hadn’t seen anyone use
/content/_index.html before (I’m used to
/content/_index.md), so I went to the docs to see how
.html files are processed in hugo (cause I know that they can be used…I’ve just never done it that way)
- Found the third paragraph under Supported Content Formats (which I think is almost the only thing said about html files for content). Which explains how hugo interprets the content of
- Had a hunch that since your
_index.html wasn’t a full webpage (no
<html><head> tags) that you probably meant for it to be processed through a layout. So guessed it needed frontmatter.
- Cloned your repository, had a look at what the output was ‘as is’, then put in the blank frontmatter…and it worked.
As for your second question - you could try running in verbose mode…which displays lots of information.
Ok, thanks. I was not aware that content pages needed a front matter to “trigger” the usage of a layout. I thought that would have been used anyway, as long as the layout structure was appropriate for the contents.
I tried verbose, but it is still not what I am looking for.
Thanks a lot!