Markdown variables in CSS file from {{ .Params.xxx }} or {{ partial "xxx" . }}

Trying to allow certain CSS elements to be edited from the markdown file. Is there any way to do this somehow:

Inside of the style.css file for example:

#banner {
background-image: url({{ partial "value.html" . }});
or perhaps
background-image: url('{{ .Params.value_from_markdown_file }}');
}

Hopefully, there is a way to do it with some kind of main config setting or something?
(The purpose is to allow the client to edit some CSS values from the markdown file)
Thanks.

Add the css as assets and process with Hugo pipes. Makes use of “ExecuteAsTemplate” and it works as you want.

3 Likes