I’ve been working on a site which is heavily data-driven; the vast majority of pages don’t have any content other than the front matter.
I’d like to be able to take advantage of my text editor’s support for YAML, but it doesn’t understand that my front matter is actually YAML, since I’m editing a markdown document.
Is there a way to get Hugo to use YAML files directly (i.e., my content would be at
content/foo.yml instead of
content/foo.md? Ideally, I’d still like to have markdown available as an option for the few pages which are just text (home page, FAQ, etc.).
You can use data files. But since hugo doesn’t a way to dynamically generate pages (at least not that I know of), you would need to find a way to transform those files into page.md files.
I wrote a ruby script to transform yml files into pages. you can see an example here. You can then run it on every build via npm.
I chose ruby just because that’s what I’m used to, but you may be able to do this with a gulp task, or even an npm script.
You could simply install a different plugin in your text editor, or even a different text editor. Atom has very good support for .md files and recognizes frontmatter perfectly.
Nice, I didn’t realize other editors supported front-matter. I’ve found Atom to be pretty unpleasant in the past, but VS Code is tolerable and seems to support it, so I’ll try to get used to it for this project…
Thanks for the info!