Can you tell me if executing templating code outside the layouts folder, for instance in a bundle resource, is possible or impossible ?
This template (which otherwise works) doesn’t do it, the page appears but golang is plain text. I surmise that what I want is impossible but would like a confirmation.
Thanks
{{ with .Resources.GetMatch "*.html" }}
{{ .Content | $.Render }}
{{ end }}
Currently it’s {{. | resources.ExecuteAsTemplate "content" . }}
but page.Page not supported in Resource transformations. why is this not working but {{ resources.Get "sass/template.scss" | resources.ExecuteAsTemplate "main.scss" . }} is fine ?
.RawContent (string) is not accepted and Content (template.HTML) neither.
If had lots of exterior html pages to include, putting them under assets/ would need the directory structure duplicated so I would rather have them as content files.
damn, I must have learnt Chinese without noticing
It’s simple. I have html files in my content directory, with a frontmatter. I want them to be published, but with the template code in it to be executed/rendered/whatever. Is it possible or not ?
Ahahah, that’s the insane wizardry I expected. A very complicated code to a simple problem . Thanks. Imho, you should put that in the site somewhere, in Single page templates | Hugo perhaps. Other people might find useful what are basically singe-use templates.
it wasn’t a criticism. it just wasn’t obvious that text or templateHTML etc are not considered “resources” because we don’t have access to a full map of internal types hugo utilize. nevermind. thanks !
Ok one last question, I tried with a mhtml file that I have, that chromium read correctly. hugo does more things than just process the templating code here, so the file gets mangled. I rename the extension to “html” then rename the output’s “mhtml”.
can I tell it to treat the file as plain text and not touch it at all beside the code ?
I wanna serve my archives or other pages and use hugo as a preprocessor of sort (beside my articles).
I have a series of mhtml files, a webarchive format. chromium (among other browsers) read it and use it to store web pages.
I want to serve them on my website. I could put them in static, but I need them as content files to write things, use templating code etc, the initial purpose of this thread.
But they’re mhtml, and so hugo ignore them… and when I change the extension to html, they become invalid with the message: Malformed multipart archive: *filename*
so is it possible to avoid touching the file at all except to expand the golang code ?
I’ll first try with custom mediatypes and outputs.