Multiple layouts for the same content

Hi,

I want to generate an ics or cal file (calendar) in addition to the content page using more that one layout (the page or post layout, and a special ics layout to generate a VCALENDAR (VERSION:2.0) file.
The latter is a link one should be able to use to add an event to one’s personal calendar.

But I did not find a way to output two files from one source, using two layouts in the docs, nor here on the forum.

I hope it is possible, otherwise I will need to duplicate some info in another collection…?

I’m using jekyll 4.0

Thank you for your time

Stefaan Huysentruyt

Focusing on the part of two files with different layouts from common info…

Add your data to a data file
_data/calendar.yml

foo: abc
bar: 123

Then you can have two layouts which have their own structure. But both use same values using this approach.
e.g. {{ site.data.calendar.foo }}

Then you have two content pages with nothing in the body but one uses one layout and the other uses the other layout.

See https://jekyllrb.com/docs/data-files

It may be that the files you output are .cal or similar rather than html or markdown which is fine. You can have another page which has an add to calendar or download button which points to one of the pages.

Thank you for your input.

Yes we will need a separate data file in use by both layouts. It is a bit cumbersome I guess, because de central data file contains in fact the core data (what, when, where, who, …) for both layouts. The more elaborate collection item needs an artificial tag or other key value to refer to the calendar data item. Nesting the calendar data using subfolders could eventually keep this manageable (eg. one folder per year or season…)

For now, the only thing we wish to be really manageable is the Corona virus…
An event calendar is now full of canceled or postponed entries.

Be safe!

You’re welcome.

Yes data in separate files or folders can work.

Also note on revising my answer above. A layout is useful for reuse and so if two pages map to two very specific layouts, you could use a more general page.html layout which is used across the site and had a heading and references the default layout. And then move the rendering of the content (with page-specific html) as two .md pages. Or maybe .cal or similar in your case, with frontmatter hyphens to get it parsed with Liquid substitution. Hoping it will keep your extension.