Remove layout under certain conditions

I have an “events” page that uses jekyll posts to list upcoming events. I am using “default” layout for the events page. That all works great. Now, I want to be able to link to an individual event/post, but I want the individual post to also use “default” layout. The problem is if I give the “post” layout a “default” layout, the individual post links all have it right but the events page is a mess of “default” layouts. How can I have all my posts on one page without a particular layout and have each post have the particular layout when they are on their own? Is it possible to remove a layout from posts under certain conditions?

not really giving us much info here, like what theme? the default one?

is there a repo to look at?

It sort of sounds like there are nested layouts of some sort, certainly what it sounds like you want should be no problem. I would look your default layout and see how it works to try and track down why it is happening. And / Or make another layout just for your events page or vice versa.

Sorry I guess assuming others are using Jekyll the way I do is a poor assumption on my part. “default” is what the whole site basically uses–header, side nav, footer, and content goes in the middle. My events page has a for loop for future posts in the content area of default and uses the default layout. This is good. My posts use a layout I call “post” which is just the event info: title, date and time, info about the event. The link to each individual post though has no layout that includes a head, header, nav, footer. Which is what I want. I want the individual post to be in the default layout. But I can’t nest default inside of default it gets wacky. I know there must be a solution to this: how do people get around providing head/structure to individual posts without including that when using the post in tumblr like feed on another page on the site? My repo is private and a little messy right now but I could throw something together tomorrow if necessary.

I already replied but the spambot removed it, I’m guessing because of my proxy…

I’m not using a theme, I started from scratch. My repo is located here: https://github.com/mwirt/detroitclothingcircle.com

I feel like this must be a relatively common issue with a simple solution I’m just having trouble finding it. How do I make a layout for posts that are on their own, as they are seen at their permalinks, but not when they are in a feed? my default layout is a head, header, nav, footer and some room in the middle for content. I have a “post” layout but its just the post content–title, date, time, description of event, image. I cant give the post layout a layout of default–while it works for the permalink, I get a bunch of heads, headers, and navs in the events page with all the posts. How do people solve this?

I should add, my “default” layout is actually called “base1” I just thought maybe there was a general understanding of the purpose of the default layout which base1 serves.

not sure about this but in your events index.html you have {{ post }} and I think maybe that is not correct. If you are building a list of posts like that usually your loop would pull out the title, conent, date, url etc and you build it like that.

I think maybe post on its own is putting the whole page in there which is pulling in all the heads and navs and what not.

Try changing post to post.title and see if you just get the title on its own unstyled.

Alright yes that’ll do the trick. I was hoping for something a bit more DRY than basically recreating the post layout in the events index but I’m not aware of an alternative. Thanks for your help!

This is where Jekyll includes come into play. Create a posts include that has all the logic and then you can reuse it in multiple places, layouts, whatever.

1 Like

aha! I knew I hadn’t truly explored the full potential of Jekyll includes. Thank you for the direction, friend.