Home template not rendering

Hi,

I have set up my Index to use a home.md content file, which should then use the _default/single.html template.

I’m using this code in index.html

{{ range .Data.Pages }}
  {{ if in .Params.tags "_home" }}
    <h1>{{ .Title }}</h1>

    {{ .Content }}
  {{ end }}
{{ end }}

and it will display the title and content from my home.md file, so it’s definitely working but it will not render any templates at all, even if I try manually setting one using “layout”.

Does anyone have any ideas why this might be?

I’m confused by your example, but I will try to guess:

Your index.html IS your home page template (I assume), and it will not automagically delegate to more templates for the rednering of the content.

You may want to look into views, partials, or even base templates, depending on your requirements (which is a little vague).

Hi,

thanks for the reply. Yeah, basically I’m trying to run index from a content file’s template instead of index being the template. I have set up a system where I have multi language data files that are determined by a “locale” setting in the content front matter.

Because I can’t set Front Matter on index.html, I wanted it to use a home.md content file that contains my “locale” setting and use the default single.html template instead.

I’ve seen my code above as a solution for this around the forum, but the template itself doesn’t seem to render for me.

Sorta. There are numerous workarounds for this - default values, blocks, partials, or even data files - depending on what you’re trying to accomplish. Can you point me to a repo?

ok cool,

I’ve actually worked around it using partials now. I just have my home page template set up completely using partials and then have a duplicate template in my templates folder using the same partials.

I’m still not sure if that’s the best way to go about it but it works for now and I can always tweak and change at a later time.

thanks for the suggestions!