Using a page with frontmatter as an include, without rendering the frontmatter?

I’m in a situation where I have a page on my site (page.html or page.md in root), the contents of which I also want to display via an include on my front page (index.html or index.md). I’m mentioning both extensions because I’m agnostic to the format for these two pages.

I’d like for page.html to be a standalone page on the site, so I included simple frontmatter with a title variable. I’m then using:

{% include_relative reporting.html %}

…to include that on my index.html page. But when I do that, the front matter dashes and title variable are also rendered, which I don’t want. Is there any way to use page.html as an include in this way without having the front matter appear?

The content of page.html is text, with simple html/markdown formatting (bold, italics, links). I’m attempting this approach because I want to be able to edit page.html with Netlify CMS in one place, and have updates appear both on the standalone page.html and on index.html via the include. I’m relatively new to Jekyll so if there’s a better approach to take here, I’d appreciate any advice. Thank you!

The easiest solution that I’m an idiot for not thinking of before posting is: I’m just going to put the content minus the frontmatter into the include, and then use that include both on index.md and under the front matter on page.md.

The include content is markdown formatted so this does appear to force me to use .md for index.md and page.md, because I can’t get the markdown to render properly when included into an .html file.

I guess that shows I shouldn’t post for help

1 Like

something like that just happened to me this morning - I wanted to include a gallery.html on the main page and in the gallery.html I wrote frontmatter that said layout: default - and that got rendered on the page.

took me a while to figure out that none of the .html files in the include directory had frontmatter … and the layout was sorted already … - so yes, me too medium smart :slight_smile: