I went over to my page today to review some of the layout to make sure it was correct and saw something very strange here.
As you can see, it is only rendering a title with the word Abouts. I don’t even know where this word Abouts is coming from because it is nowhere in my website structure.
Without looking in detail at your repo, my guess is that you should look at pluralizeListTitles and make sure it’s set to false…but that’s not the real problem here. I think your about page is pulling from a list template rather than a single page. Also, if you want to add content to about, it might be best to just create a directory called “about” inside of content and then add an _index.md file that contains the desired content for the page. Look up the lookup order for templates for v18 in the docs. HTH.
If the mardkdown file does not have any frontmatter, then it is not rendered as a content file. I will be treated as a special case, and will be its own template (i.e. no layout handling).
It doesn’t matter if the file does or doesn’t have front matter, it’ll still not be rendered in certain cases.
I’m guessing it’s to do with the template that renders the section.
I’ve set up a test case for you to see. You can fork/clone the repo at the address below and try view the /about/ page. It won’t be rendered correctly (you’ll just get empty list being rendered by the /theme/layouts/_default/list.html template) and you can see it has front-matter etc:
It’s possible I’ve misunderstood how this _index.md thing is intended to work but to my mind it should be rendered using the /theme/layouts/_default/single.html template. However, that’s not being used for whatever reason - and that is the problem here with OP too I think.
NOTE - I know the template hierarchy, I’ve checked there are no other templates interfering.
I am still learning Go templates so it’s possible there’s something obvious regarding how the theme is setup but at least there’s another concrete example to compare against and see it not working.
^ The above statement is a misunderstanding. _index.md is (currently) always a list page (home page, taxonomy list etc.), and will get a template chosen accordingly. See the documentation.
Yep, I understand now, I was just going to write a separate tips and trick post to clarify that, but now I’m not sure, perhaps a doc clarification would be better.
I understand that it’s ‘obvious’ this behaviour is true (indeed, I know it without looking up the docs and exploit the behaviour for the other site sections) but the docs on Source Organisation give the impression that all you have to do is add an _index.md file.
That’s not the case - you actually have to ensure that your list.html template (or corresponding section template) is setup to render {{ .Content }}. Again, potentially ‘obvious’ but a departure from my thinking as I really only render {{ .Summary }} on list templates - so I didn’t make the leap.
I presumed (my bad, never presume!) that Hugo would detect an _index.md file and simply grab the single.html template to render it. This was probably based on my use case and it wouldn’t necessarily be a good idea to actually do that now I have more time to think about it (it would introduce a divergent behaviour from the logic of the template hierarchy).
However, perhaps the docs on the Source Organisation page could be updated to clearly state this for the folks like me who need to be slapped with the info again?
@JoshArcher If you want the content from _index.md to render, add {{.Content}} to your _default/list.html. That said, for more specificity, you can create a _default/section.html page that will be the default layout for all your index pages in your site section.
That said, @bep, are list/section layouts designed to ignore {{.Content}} if, for example, a site has three sections, but only two of them have _index.md. If not, @JoshArcher, you can set up a conditional…
I would write more, but I’m on my phone on the airport. HTH.
Thanks. I see you’re on your mobile which might be why you didn’t see I’d already worked that out and written it up above. I put a separate tips and tricks post together to highlight this stuff too, just in case it trips anyone else up.