New layout for a single page inside the posts directory

Basically, I am using a theme and need to tweak new things.

These are the three posts that I have. The folder structure is as follows:

  1. content/posts/first.md
  2. content/posts/second.md
  3. content/posts/tab.md

I want to have a new layout when I click the third post “tab”. The layout should have an iframed dashboard while the layout for other posts should be completely different.

I was able to get an iframed dashboard in the third post “tab.md” by putting the file inside content/posts/dashboard/tab.md and creating a new layout /layout/dashboard/single.html. But when I did this the third post “tab.md” disappeared from the first screenshot. However, I can access it by doing localhost:1313/tab

Also I tried setting the type:“dashboard”. But this forces all the posts to have the iframed dashboard.

So, how do I create a new layout just for this post.

Thanks in advance!

  • in tab.md set layout= tab (in fromtmatter)
  • rename /dashboard/single.html to /dashboard/tab.html

Thankyou for the reply @ju52 . It still does not work.Things I did:

  1. Added tab.md in content/posts/dashboard/tab.md
  2. Changed filename and added it to layout/dashboard/tab.html
  3. In tab.md set the layout: tab (in frontmatter)

The link localhost:1313/tab redirects to the new layout with the iframed dashboard. But it does not show in the list of posts (as shown in the screenshot)

can you setup a sample repository?

Yes sure. Thankyou so much for the help @ju52

I stripped it to basics.

The page is generated with themes/…/layouts/_default/list.html
you can copy this file to layouts/posts/list.html and modify it.

You can add the iframe at line 52

<iframe class=my_iframe name= title= >
      content ...
</iframe>

if you use a different name listframe , add to content/posts/_index.md

layout = list2

in frontmatter. so you can trigger the iframe.

this as a start