Hello, a question for someone who understands how output formats work.
I see from https://gohugo.io/templates/output-formats that I can create a page in that format, but, what I’d like to do is generate a vcard for records in a json file in data. I want to let visitors be able to quickly download the vcard for each contact.
Because vcards can have multiple entries in a single text file, I assume I can make one custom template for a single page that represents a big vcard with lots of entries, pulling from the json. I’m not sure if this is useful for people though in practice.
Of course, I can always mark up the records in html in “hcard” microformat (range over the json from data and make a table on a page, with the microformat markup), but, that depends on browser plugins to work. I can also parse the json into vcards with a separate script before generating the site, but, I’d like to see if I can somehow get hugo to do it.
Any advise appreciated. Thanks!
Missed it by that much. If anyone else comes looking, I just wrote up a post on just how to do this.
Basically you need to add an outputFormat to your config
Then add outputs to a page type
Then add the template in /layouts/_default/contact.vcf.
This outputs a contact.vcf file for each page.
Thanks @matt-antone, I will see if I can incorporate that idea to range over data.
I haven’t tried it in this case, but I think you can limit which pages get the treatment using a content type.
The docs say:
outputs definition is per
taxonomy , or
But you spurred me on to read a little further. Turns out you can specify the output at the page level. If you add the outputs at the page level, this fixes the necessary .vcf files issue: