Which concrete view does .Render "default" resolve to?

A theme I am using has a layout/_default/single.html with the following statement:

{{ if <one of a list of specific sections> }}
  do something for that section
{{ else }}
  {{ .Render "default" }}
{{ end }}

I assume “.Render default” in the end refers to another content view but which one? Isn’t this particular view default/single.html already the default one? The documentation about this topic only contains a trivial example.

Note 1: this is from theme airspace-hugo, airspace-hugo/single.html at master · themefisher/airspace-hugo · GitHub

It renders the default content view for a given page.

For example as per the content files that will be outputted as normal pages and their corresponding templates under layouts of the airspace-hugo theme:

content/en/about.md will use layouts/_default/about.html
content/en/contact.md will use layouts/_default/contact.html
content/en/faq.html will use layouts/_default/faq.html
content/en/message_sent.html will use layouts/_default/message_sent.html
content/en/pricing.html will use layouts/_default/pricing.html
content/en/service.html will use layouts/_default/service.html

Basically the .Render function and the content view templates function pretty much the same as partial templates.

This is simply just another way to organize a Hugo project.

Awesome, thanks for the explanation.

Followup question: under which circumstances in your example would layouts/_default/single.html be called?

Basically, now I wonder if this particular template is just silly as I can’t see the else how the single.html layout is called and then finds a default layout foo.html in the else branch, if foo.html was available could have been called directly rather than single.html. :thinking:

Do you happen to know of a way to print at runtime which layout file has actually been used?

It is always called for single pages. As per its structure in the airspace-hugo theme different HTML is rendered depending on the set conditions.

The aforementioned content views are more like page components that are rendered in their respective pages.

There is a theme component called debugprint that is available here from what I remember it used to print the PATH of the template that was used for each page. However as per its current demo it appears that this is no longer the case.

1 Like

To clarify: this is looking for a content view template named “default.html”. The word “default” is a literal string; it is not a keyword or token. I do not understand why the theme author included this code without a corresponding template.

Here’s the lookup order for content view templates:

Try it:

git clone --single-branch -b hugo-forum-topic-35507 https://github.com/jmooring/hugo-testing hugo-forum-topic-35507
cd hugo-forum-topic-35507
hugo server

When you first build the site you will see this:

That’s happening because there is not a content view template named “default.html”.

Now, rename layouts/_default/post.html to layouts/_default/default.html and rebuild the site.


Now I saw that within each content file the theme author specified the layout parameter to the corresponding template.


Discard what I wrote above. @jmooring is correct default is a literal string.

Each content file has a layout parameter hence the respective templates are used.

If the layout parameter is removed then these pages will render without their content due to the construct in layouts/_default/single.html:

{{ else }}
  {{ .Render "default" }}
{{ end }}

It appears that the above construct is perhaps a draft, try asking the Themefisher people at their GitHub repo.