# Adding multiple content variables in one layout file?

**URL:** <https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997>\
**Category:** Help\
**Created:** [May 5, 2021, 6:59pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997 "2021-05-05T18:59:01Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ampersamd](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/ampersamd/32/3530_2.png) [@ampersamd](https://talk.jekyllrb.com/u/ampersamd)\
**Post date:** [May 5, 2021, 6:59pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997/1 "2021-05-05T18:59:01Z")

</div>

Hi all,

I’m new to Jekyll and trying to figure out how to modify the site I’ve been given, specifically the layout files.

The layout file is using Dynamic tabs in the form of nav-pills. The site originally had two tabs, the first with some in-file html code and the second contains the {{ content }} variable. I’ve added a 3rd tab and my question is how do I add another {{ content }} variable that will reflect a page2.md file that I have while maintaining the original {{ content }} link to page1.md?

My code is similar to the below:

```auto
<div class="tab-content" id="pills-tabContent">

  <div class="tab-pane fade show active" id="pills-view" role="tabpanel" aria-labelledby="pills-view-tab">
    <div>
       [Some unrelated in-file HTML]
    </div>
  </div>

  <div class="tab-pane fade" id="pills-compare" role="tabpanel" aria-labelledby="pills-compare-tab">
    <div>
      {{content}}
    </div>
  </div>

  <div class="tab-pane fade" id="pills-glossary" role="tabpanel" aria-labelledby="pills-glossary-tab">
    <div>
      {{content}}
    </div>
  </div>
</div>

```

How do I get the {{content}} variable associated with pills-glossary tab to display a specific .md file I have?

---

<div class="post-metadata">

**Author:** ![victorb](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/victorb/32/5112_2.png) [@victorb](https://talk.jekyllrb.com/u/victorb)\
**Post date:** [May 6, 2021, 12:51pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997/2 "2021-05-06T12:51:32Z")

</div>

You could do something like

\_includes/template.html

```auto
<div>
    {{ first-section }}
</div>
<div>
    {{ second-section }}
</div>

```

page.md

```auto
{% capture first-section %}

Here is my first section content!

{% endcapture %}

{% capture second-section %}

Here is the second section!

{% endcapture %}

{% include template.html %}

```

---

<div class="post-metadata">

**Author:** ![ampersamd](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/ampersamd/32/3530_2.png) [@ampersamd](https://talk.jekyllrb.com/u/ampersamd)\
**Post date:** [May 6, 2021, 1:04pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997/3 "2021-05-06T13:04:01Z")

</div>

Thanks! How would I call those sections in my template file… Just use {{ first-section}} or would I need to use an include call to pull the .html file?

---

<div class="post-metadata">

**Author:** ![victorb](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/victorb/32/5112_2.png) [@victorb](https://talk.jekyllrb.com/u/victorb)\
**Post date:** [May 6, 2021, 1:05pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997/4 "2021-05-06T13:05:51Z")

</div>

Ah yes sorry I forgot a part, you need to add

```auto
{% include template.html %}

```

at the end of page.md

---

<div class="post-metadata">

**Author:** ![ampersamd](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/ampersamd/32/3530_2.png) [@ampersamd](https://talk.jekyllrb.com/u/ampersamd)\
**Post date:** [May 6, 2021, 1:16pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997/5 "2021-05-06T13:16:11Z")

</div>

Got it!

When I’m referencing the sections that I created in my layout file, I’m using {{ section 1}} and {{ section 2 }} but that doesn’t seem to be working. Is this another way to call these sections in the layout file, similar to how the {{ content }} variable would work?

---

<div class="post-metadata">

**Author:** ![victorb](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/victorb/32/5112_2.png) [@victorb](https://talk.jekyllrb.com/u/victorb)\
**Post date:** [May 6, 2021, 1:18pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997/6 "2021-05-06T13:18:08Z")

</div>

It doesn’t seem to work in layouts, from what I read on StackOverflow, so you have to use include

---

<div class="post-metadata">

**Author:** ![ampersamd](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/ampersamd/32/3530_2.png) [@ampersamd](https://talk.jekyllrb.com/u/ampersamd)\
**Post date:** [May 6, 2021, 1:40pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997/7 "2021-05-06T13:40:35Z")

</div>

Makes sense. Any idea what the right syntax for that would be? I’m trying the following, but it’s not compiling. I’m sure I just need to set something to section-one instead of just passing it in, but I’m not sure what.

```auto
{% include template.html section-one %}

```

---

<div class="post-metadata">

**Author:** ![victorb](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/victorb/32/5112_2.png) [@victorb](https://talk.jekyllrb.com/u/victorb)\
**Post date:** [May 6, 2021, 1:42pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997/8 "2021-05-06T13:42:24Z")

</div>

You shouldn’t need to pass it at all, just including it. I just remembered I did a gist explaining that for another post so here it is, if it can help you : [\_includes index.html · GitHub](https://gist.github.com/victorbnl/3a40ed5e797759bbff614547e634a98f)

---

<div class="post-metadata">

**Author:** ![ampersamd](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/ampersamd/32/3530_2.png) [@ampersamd](https://talk.jekyllrb.com/u/ampersamd)\
**Post date:** [May 6, 2021, 1:57pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997/9 "2021-05-06T13:57:42Z")

</div>

Did you use those sections you created in a layout file anywhere? Just not sure how to use the include there.

---

<div class="post-metadata">

**Author:** ![victorb](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/victorb/32/5112_2.png) [@victorb](https://talk.jekyllrb.com/u/victorb)\
**Post date:** [May 6, 2021, 2:59pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997/10 "2021-05-06T14:59:13Z")

</div>

What I told you was just a hacky solution anyway, I just found this plugin which seems very good : [GitHub - rustygeldmacher/jekyll-contentblocks: A Jekyll plugin giving you something like Rails' content\_for](https://github.com/rustygeldmacher/jekyll-contentblocks)

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [May 6, 2021, 3:31pm UTC](https://talk.jekyllrb.com/t/adding-multiple-content-variables-in-one-layout-file/5997/11 "2021-05-06T15:31:24Z")

</div>

the only way to include page2.md is if it is an include. But then it would not be its own page and other than being able to include it on another page I don’t see an advantage.

Why can’t you just use html like the first one does?

another option is a data file, I use it for things that repeat a pattern like faqs.
