-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: multiple formats per page using layouts #3041
Comments
+1 for this, I'd like to generate static JSON for some of my pages too... |
@benbalter any thoughts on this? Seems the kind of thing you might find useful. |
Yesssssss. I swear I opened an issue for this a while back, but can't seem to find it. All for this (json is my use case), but can't think of a sane ux. Perhaps a layouts key which accepts an array? |
I figure you have the same layout name, so nothing changes post-side, but you just render all layout formats with the same base name, i.e. 'layout.html' and 'layout.json'. |
Obviously this would only work well for pages and posts that have most of their data in the yaml front matter, otherwise rendering to JSON would be kind of meaningless anyway. |
Makes sense. @parkr any strong opinion on this? To me it's in line with Jekyll's do what I ask, no more, no less philosophy, and does exactly what you'd expect. |
Only strong opinion is that it's backwards-compatible. A layout like In general I'm 👍, but it's going to be a pretty heavy lift. Any help would be greatly appreciated. |
@parkr: I'm thinking more that the pages would remain the same, just referencing |
very cool 👍 |
Interesting! What happens when I have |
I'm liking @Floppy's implementation. Sure there's an edge case where I only want one and get both, but I'd argue that (A) that's an edge case (I can't think of an example), and (B) there's no risk to having an extra CSV file that nobody views (and (C) just make a new layout). Not worth the 10 fold complexity to handle it. |
I'll definitely look at an implementation, but I'm skeptical that it's the best UX going forward. Any magic causes confusion and makes Jekyll harder to use. This is borderline magic. How does it work when a layout has a layout and the parent layout has two extensions? |
Ugh. Hate working with @parkr. Always crushes my dreams with his "logic". Jekyll philosophy dictates:
Is this an inaccurate description of current user practice?: Users create a layout (let's call it What if we extend the design pattern of plurals and say |
I think, for the nested layout case, if we had |
Not many, in my opinion. A json layout is the only compelling use case I can think of for this feature. It's something I'd use, but is it something 80% of our users would use? Not sure. It would certainly make API-ifying your posts, for example, a whole lot easier. Layouts are meant to make it all easier. We just have to make sure it's still easy to understand – i.e. keep the cognitive load as low as possible.
Imagine writing a page you want for both layouts and you type |
If you want formats to be explicit in the frontmatter, then perhaps it's better to leave layouts alone and add a format(s): [html, csv] option to the frontmatter? Jekyll would explode in the usual way with unknown layout if the right layout extension didn't exist... As for use cases, a couple of thoughts;
I'm sure there are more, but these are the ones that spring to mind quickly. I'm interested in seeing just how data-capable we can make github/jekyll/pages etc, and so these are all things that I'd love to be able to do. |
@Floppy I possibly want multiple html views of the same documents. (e.g.: one formatted as a presentation, and the other as a blog post.) I like your idea of explicitly specifying the layouts to use in the frontmatter. (whether directly specifying the layout or indirectly by specifying the format) ASIDE: If you want an ical for the whole site, you could generated one like rss and sitemaps. Just add |
That's interesting, and would suggest that @parkr's idea of having multiple layouts with optional extensions might be better, so you could have Also, good point on the ical :) |
That was an astonishingly useful suggestion, I have implemented it here: http://rawfunkmaharishi.uk/calendar.ical , https://github.com/rawfunkmaharishi/rawfunkmaharishi.github.io/blob/master/calendar.ical (this may not be 100% correct, I have just Cargo-Culted my way around iCal) Thanks :) |
@kbrock Actually two layouts with the same extension would cause name conflicts on the generated files, so that shouldn't be allowed unless we allowed layouts to specify their naming convention for the output, which is a whole other matter. |
PR in the works? Thoughts? |
I've not had time to spend on this yet, but I've not forgotten about it... |
Is there a PR for this yet? |
(I withdraw my request to allow multiple html files from one document) Anyone able to share the current proposal?
|
Some thoughts on the proposal:
|
👍 |
👍 I wrote a plugin a while back to accomplish this (https://github.com/saclark/jekyll-multipost) but standard support for this would be ten times better. |
@0maxxam0 has funded $60.00 to this issue. See it on IssueHunt |
Wow, 4 years old and I've still not started working on this. It'll be old enough to go to school soon. 🍰 |
@Floppy the multipost code looks like a good start. |
@issuehuntfest has funded $100.00 to this issue. See it on IssueHunt |
@rororofff has funded $2.00 to this issue.
|
@0maxxam0 has funded $40.00 to this issue.
|
@serima has funded $2.00 to this issue.
|
@amthe has funded $2.00 to this issue.
|
I would like to share an alternative way using a plug in called jekyll-redirect-from that also available on github pages via this setting on
Based on your case of a post called Using different extension but with the same name of layout will not be possible, so we will need to move them in a different folder than In
In
Arrange redirection in your post
In
In
As result the output of |
Oh, @Chetabahana, that is a clever hack - I love it :) |
A bit late to the party, but I would also like to see this feature implemented. I would like to have multiple layouts available per post so that I can branch what a post looks like based on how you got to it. Example: All posts list -> post -> post list still show all posts while viewing post. Simultaneously: Filtered posts list -> post -> post list still show filtered posts while viewing post |
Almost a decade later, the generalized plural option for layouts, where either I propose the following:
|
Wow! This issue has been incubating for almost a decade now.. Wonder how many of the those desired this feature is still using Jekyll... |
🖐️ |
We are using Jekyll for NSDI data specifications and need this feature for content negotiation. |
Still using Jekyll. Still desire this feature! Agree with @bloombar's approach which should apply only in the case of a filename clash. E.g. Files in _layouts:
Inside c.json is also the frontmatter: So:
This allows you to preserve simple filenames for the use case of "one piece of content in multiple formats". In the case where you specify two layouts with the same format, the latter layouts are considered "alternatives" and so the filename is appended with the name of that alternative (the first layout specified is considered "primary"). |
@Convincible - thanks for the detailed description. There are two issues here that might be best kept separate:
The first seems relatively straightforward, if a simple rule is devised like the one you and I have suggested. I believe the second issue might be a bit more challenging, since jekyll does not seem to currently support any content type besides |
Put me in the camp of someone who also wants this, and who has used Jekyll (off and on) for much of this time. :) What have other folks been doing in the meantime to get multiple outputs? I might have a slightly unexpected use case for a project soon, which is to generate both a PDF and HTML version of page. However, it seems like Hooks should be able to do this, perhaps |
What I usually do is create a hook plugin that filters the documents that need another format and create a |
I have a similar use case, but rather than create a Jekyll plugin, I personally found it easier to use my own custom GitHub Actions workflow to render the PDFs after running Jekyll. |
I have also used GitHub Actions to convert formats after the site is built. I had been planning conversion to PDF using pandoc, but your headless Chrome solution looks nice.
… On Nov 15, 2023, at 10:13, Sesh Sadasivam ***@***.***> wrote:
I might have a slightly unexpected use case for a project soon, which is to generate both a PDF and HTML version of page.
I have a similar use case, but rather than create a Jekyll plugin, I personally found it easier to use my own custom GitHub Actions workflow to render the PDFs after running Jekyll.
https://github.com/seshrs/build-primer-spec-action/blob/62703e09107f7d70f6e83f2a60b2690bbe33d98d/action.yml#L77,L92
—
Reply to this email directly, view it on GitHub <#3041 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAQ3KSW7AQPOA6VVVMLUKCTYETLY5AVCNFSM4AWTM5W2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOBRGI3TEMBYGU3Q>.
You are receiving this because you were mentioned.
|
As far as I can tell, it's not possible to have two output formats for a single page/post at the moment.
We have a case where we'd like to generate an iCal file for each post, as well as the HTML version. It seems to me that a nice way to do this would be to allow multiple extensions for each layout, and generate a file for each extension in the specified layout.
For instance, if we had a post
2014-10-30-hello-world.md
, and two layouts,_layouts/post.html
and_layouts/post.ical
, you would end up with output in both/2014/10/30/hello-world.html
and/2014/10/30/hello-world.ical
.I'll have a go at this when I find time, but I was wondering if anyone could highlight any fundamental reasons why this wouldn't work, or problems that might be encountered when writing it?
The text was updated successfully, but these errors were encountered: