[SOLVED] Why does this build XML rather than HTML?

Hi guys,

Firstly apologies for this incredible banal post - I’m certain I’m doing something very basic very wrong. Just trying to get to grips with Hugo for the first time.

https://github.com/jonnykates/testinghugo

I can’t figure out why Hugo fails to build my content/about/_index.md file properly. I am starting with a completely blank theme; for which I thought I have scaffolded the layouts correctly. To my mind, it should be using layouts/baseof.html as the template for building my about page.

Any pointers would be amazing - sorry again for being useless!

Jonny

One thing to note is that all _index.md pages are considered list pages, so they when it comes to the Hugo lookup order, Hugo is going to look for a template at layouts/_default/list.html to render your content/about/_index.md.

Since I’m not 100% on what you’re trying to do, it’s also worth nothing that a file at content/about.md is going to render–at least at the terminus of the lookup order–via the template you create at layouts/_default/single.html because it’s then a single content page and not a list page.

[[UPDATE]] I took a quick look at your GH repo, and to add to the comment I made above re: list page, it looks like your default list.html does not have anything in it, so Hugo has nothing to look to to render the page

https://github.com/jonnykates/testinghugo/blob/master/themes/jfk/layouts/_default/list.html

It also look like you do not have any blocks defined in your layouts/_default/baseof.html:

https://github.com/jonnykates/testinghugo/blob/master/themes/jfk/layouts/_default/baseof.html

Here is an example of what you’re probably looking for…

<!--layouts/_default/baseof.html-->
{{ partial "header.html" }}  
    {{ block "main" . }}  
      {{ .Content }}  
    {{ end }}
{{ partial "footer.html" }}

Then in your layouts/_default/list.html you can do something like the following:

{{ define "main" }}
<h1>{{.Title}}</h1>
  {{ .Content }}
{{ end }}

Note: In layouts/_default/list.html the code you put inside the main block will overwrite whatever you include inside the main block in baseof.html as “default” content.

Thanks for your replies, hugely helpful. I’ll dive back into it later - I only have a couple of minutes but I wanted to just say thanks.

When I named the content file _index.md, I was trying to follow the organisation example as per the documentation:

└── content
    └── about
    |   └── _index.md  // <- http://1.com/about/

If that’s a listing page, what exactly is it listing? There are no other child items or sections within that /about/ parent. To convert it to a ‘single’ page type, is it a case of removing the prefixed underscore from the markdown file?

I think the new explanation in the concept site might help. I normally explain in the forums, but I’m at work :smile: Basically, it’s “listing” all the pages in that section…even if it’s just a list of one. I also appreciate this is confusing, but it comes in so damn handy as your sections grow. Technically, everything is a “page” in that everything now has access to page variables.

If you want Hugo to see your /about page as a single content page, you can also just move it to content/about.md in your source. Please LMK if you have anymore questions.

Ah OK! I think I’m getting somewhere now :smile:

Thanks for indulging me - appreciated. Solved.