[SOLVED] How to implement Homepage as markdown / toml file?

I would like to use frontMatter in my homepage and render the _default.html template instead of /layouts/index.html. Is this possible?

Rationale:

1 - I use frontMatter to dictate metadata for opengraph etc. this renders in my header and it seems odd that I can’t add it to my homepage.

2 - My _default.html file currently renders identically (minus the meta) to the homepage, I don’t like having to repeat myself in these two files.

Any advice would be greatly appreciated :slight_smile:

Use blocks (baseof.html template(s)) – but be aware of

If you use “complicated block structure” – then you need to build the latest Hugo.

As the the opengraph metadata, I would say it should be pulled from the site config on the home page …

I don’t much fancy this - my theme is being geared up for a CMS style editor, it’s seems a shame to have a single edge case whereby I’m reading and writing two files instead of just the one. It would come with added complications when having to respect existing config.toml values instead of (as I currently do) just overwriting the entire frontMatter section.

I’ll see if I can abuse the permalink system; create an archetype for the homepage and do something like this:

[permalinks] homepage = "/"

Probably a fools errand :blush:

edit - yep, a fools errand :cry:

Hmm - is there a simple (enough) way of loading a content file into a variable?

I think in this manner I could have my index.html file read a content file and then replicate the _default.html functionality using this data…

Making headway with Block templates, I’ll post my results :slight_smile:

So, my solution was along the same lines as the hugoskeletonsite theme whereby the homepage ranges through the content and uses whichever page is tagged with “homepage”.

<!--
    This homepage simply outputs the first content page with
     a frontMatter type="homepage". It should be identical to
     the "page" template when rendered.
-->
{{- range first 1 (where .Data.Pages "Type" "homepage") -}}    
    {{ partial "head.html" . }}
    <article>
        {{ .Content }}
    </article>
    {{ partial "foot.html" . }}
{{ end }}

Whereby the partials must be careful to not use .File vars as these are only available to Pages, but not Nodes like the homepage.