Use the variables from the site/page/etc... in a html file

I would like to generate my cv (html file) with a html template (for example, content/cv.html).
and in this cv, just use the {{ .Params }} or {{ .Site }} etc… but in the result, the template engine does not recognize the {{ .Site }} variable and will show the textual syntax. Have you an idea ?

Thank you

This might not be the most elegant method, but you can create a new page type called “cv”, and then create a file called cv/ in the root of your content, with nothing in it but frontmatter.

Then, in your layouts directory (either in your site, or in your theme if you have your own theme) create cv/single.html, and in that file, put all your fancy HTML including any calls to site variables, etc. You might need to include some partials and stuff; this is definitely me typing quickly just to get it out there for how I’ve solved for this before.

One final thing would be to probably add

	cv = "/:filename/"

to your config.toml so that the cv path is on the root, and not in cv/cv, you know?

You should be able to use site Params in layouts, but they won’t work in a markdown file. For that, you should look at shortcodes. See the docs.

Other than that, I would need more code examples to see what you’re trying to do.

Yeah, a shortcode would be far more elegant :slight_smile:

Thank you, I have tested and the solution works fine. Thank you.

1 Like