I am experimenting with a directory based archetype. I would like it to generate a rmd (R Markdown) file which will be rendered through R to a md file. For hugo it should look like a plain md file.
I want to fill in the title and date such as in the markdown template, but the file should be served as raw text.
I was unable to find any information how to expand templates in files with other extensions. At the moment I use the extension md - but now I need to add the file to the ignoreFiles - which is not a problem, though if I would like to share it I would need to manually copy it to a non-md extension.
I thought I could solve it through setting mediaTypes - but I was unable to figure it out.
And by defining a _default/single.md template with content
{{ .RawContent }}
Note that Hugo still tries to parse the markdown so all your shortcodes need to work.
However I don’t know of any way how to do the reverse - parse rmd files as markdown. There is no “inputFormats” configuration to choose between plain text / html / or markdown parser.
Thanks I will try this settings.
The information in https://gohugo.io/templates/output-formats/ is quite confusing for me. I chose text/plain as it seemed to be the most fitting for markdown.
Unfortunately this didn’t help. Maybe I need to clarify what I want to do.
In R you can generate markdown from a “rmarkdown” template. Usually it has the extension .rmd. (The conversion happens in Makefile line 23).
I want to have an archetype that I currently call r-bundle which contains some code files. In these files - most important source.rmd but also others I would like to have some strings expanded. think title: "{{ humanize .Name | title }}". So that I can create an entry doing hugo new -k r-bundle post/test-post.
Then I call make all_rmd - which will then create the markdown with shortcodes for linking inside the bundle.
For that kind of posts it is common to provide the source code - so ideally I would like to provide the .rmd file.
Currently I have an either-or situation. If I use the extension .md for my source code the short codes will be filled in - but I will need to ignore the “unrendered” source - unfortunately then I will need to trick again to make the plain source downloadable again.
Alternatively I can have the input file as .rmd - but templates will not expand.