Static Page in Content Not Rendering Correctly

Hi,

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.

[Here is a link to the markdown that should be rendered for this page.] (https://github.com/atbe/atbe.me.working/blob/master/content/about/index.md) Along with the code for the remainder of the site.

Any help would be appreciated. I’ve been searching through my code for about an hour and can’t seem to find the culprit.

Thanks!

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.

1 Like

Thanks for responding!

My about page is in content/about/index.md, I just moved it to _index.md

The markdown document doesn’t have any frontmatter. I’m not sure if that’ll affect things.

pluralizeListTitles is set to false now, thanks for pointing that out. Once I moved the index.md to _index.md, the title is gone as well.

How can I see which template is used to build the page?

edit update:
I added in a simple frontmatter with a title and that showed up fine. But the content of the document is not being rendered.

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.

So what do I do in order to debug a file with frontmatter that won’t render the body?

Contents of the post:

---
title: "About"
type: post
---

ELLO

### Resume
[Click here to see my current resume.](/files/resumes/current_resume.pdf)

Location of the post: /content/about/_index.md

For debugging purposes, I’m running:

Hugo Static Site Generator v0.18.1 BuildDate: 2016-12-29T12:12:41-05:00

There are two reproducible test cases here with the same failure - list template being selected over single.

If there’s no update here in the next 24 hours detailing an obvious mis-configuration I’ll open an issue on GitHub.

You can start by

  1. Fixing your project so it actually builds (invalid theme submodule ref)
  2. Fix your naming URL conflict in the /about section (rename to _index.md?)

I cannot start with those points because those points are not applicable to my repo:

This repo builds correctly and does not contain a URL conflict or need for the index file in the about section to be renamed to _index.md

They are applicable to the thread starters repo. I thought you talked about the same issue. If not, please create a new thread.

Sure, I shall start a separate thread.

The issue I have is the same as the OP, though my repo doesn’t contain those errors you mentioned - but a separate thread would probably be prudent.

And _index.md is NOT rendered sing the single.html template.

I’m sorry, I don’t understand this. Could you explain?

^ 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?

@atbe I think this post may give you the answer you were looking for (hopefully!).

@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.