# Pull feature post to home page

**URL:** <https://zola.discourse.group/t/pull-feature-post-to-home-page/829>\
**Category:** Support\
**Created:** [March 14, 2021, 12:59am UTC](https://zola.discourse.group/t/pull-feature-post-to-home-page/829 "2021-03-14T00:59:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ky2X1j8Tkrh](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@Ky2X1j8Tkrh](https://zola.discourse.group/u/Ky2X1j8Tkrh)\
**Post date:** [March 14, 2021, 12:59am UTC](https://zola.discourse.group/t/pull-feature-post-to-home-page/829/1 "2021-03-14T00:59:05Z")

</div>

First, thank you the author of Zola who creates a so great software.  
I’m new to this and still learning.

When creating a homepage, is there a way to pull the title, & partial content of certain post (based on date, or name…)

\content  
|-\>\post  
|-\>\post\post1.md  
|-\>\post\post2.md

is there a way to put the title & and partial content of post1.md or post2.md to the siteroot\index.html?

I know I can render the content if I have it in the \_index.md. but if it can pull directly from the post, that’ll be great.

Something like “last news” or “feature story”…

Thank you again for any help.

---

<div class="post-metadata">

**Author:** ![Marco](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/marco/32/478_2.png) [@Marco](https://zola.discourse.group/u/Marco)\
**Post date:** [March 16, 2021, 2:09pm UTC](https://zola.discourse.group/t/pull-feature-post-to-home-page/829/2 "2021-03-16T14:09:47Z")

</div>

Hi @Ky2X1j8Tkrh,

if you keep all your posts in the post folder, there’s an easy solution.

```
{% set post_section = get_section(path="post/_index.md") %}
{% for post in post_section.pages %}
  <div><a href="{{post.permalink}}">{{post.title}}</a></div>
{% endfor %}

```

the `get_section` function gets a section object. You can use that to retrieve all pages direct in the post folder.

This example just generates a list of of links to the posts, but you have access to [all variables of a page object](https://www.getzola.org/documentation/templates/pages-sections/#page-variables).

Also have a look at the functions available in [tera](https://tera.netlify.app/docs/#built-ins), that’s the template engine used by zola, You can use these to apply filter to the section.pages list and only print those that you want on your homepage.

I hope this helps you get started.

---

<div class="post-metadata">

**Author:** ![Ky2X1j8Tkrh](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@Ky2X1j8Tkrh](https://zola.discourse.group/u/Ky2X1j8Tkrh)\
**Post date:** [March 16, 2021, 8:28pm UTC](https://zola.discourse.group/t/pull-feature-post-to-home-page/829/3 "2021-03-16T20:28:24Z")

</div>

Thank you @Marco, I’ll try that.

---

<div class="post-metadata">

**Author:** ![Marco](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/marco/32/478_2.png) [@Marco](https://zola.discourse.group/u/Marco)\
**Post date:** [March 17, 2021, 7:45am UTC](https://zola.discourse.group/t/pull-feature-post-to-home-page/829/4 "2021-03-17T07:45:57Z")

</div>

No problem,

if you have more questions, just ask.

---

<div class="post-metadata">

**Author:** ![Ky2X1j8Tkrh](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@Ky2X1j8Tkrh](https://zola.discourse.group/u/Ky2X1j8Tkrh)\
**Post date:** [March 24, 2021, 3:09am UTC](https://zola.discourse.group/t/pull-feature-post-to-home-page/829/5 "2021-03-24T03:09:22Z")

</div>

in the

> [@Marco](#):
>
> `{% set post_section = get_section(path="post/_index.md") %}`

the section “post” was hard coded in.

If I want to set it in the config file like

[extra]  
featureSection = “post”

then use it like  
{% set post\_section = get\_section(path=“{{config.extra.featureSection}}/\_index.md”) %}

it’ll error. is there a proper way to do this?

Sorry can not find the get\_section doc online.

Thank you.

---

<div class="post-metadata">

**Author:** ![Marco](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/marco/32/478_2.png) [@Marco](https://zola.discourse.group/u/Marco)\
**Post date:** [March 24, 2021, 6:53am UTC](https://zola.discourse.group/t/pull-feature-post-to-home-page/829/6 "2021-03-24T06:53:47Z")

</div>

Hi @Ky2X1j8Tkrh,

Yes there is a way to do this without hardcoding the section.  
You were almost at the right solution.

When you look at the code here:

```
{% set post_section = get_section(path=config.extra.featureSection ~ "/_index.md") %}
{% for post in post_section.pages %}
  <div><a href="{{post.permalink}}">{{post.title}}</a></div>
{% endfor %}

```

You don’t need the braces {{config.extra.featureSection}}, because you are already inside a block using {% %} style braces.

The second change is that you need to concatenate the string value using the ~ operator. That’s the way strings are concatenated in the tera template engine.

Does this anwser your question?

Marco

---

<div class="post-metadata">

**Author:** ![Ky2X1j8Tkrh](https://avatars.discourse-cdn.com/v4/letter/k/e8c25b/32.png) [@Ky2X1j8Tkrh](https://zola.discourse.group/u/Ky2X1j8Tkrh)\
**Post date:** [March 24, 2021, 3:16pm UTC](https://zola.discourse.group/t/pull-feature-post-to-home-page/829/7 "2021-03-24T15:16:53Z")

</div>

Thanks @Marco again. it works.

---

<div class="post-metadata">

**Author:** ![Frokost](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/frokost/32/800_2.png) [@Frokost](https://zola.discourse.group/u/Frokost)\
**Post date:** [July 20, 2022, 3:12pm UTC](https://zola.discourse.group/t/pull-feature-post-to-home-page/829/8 "2022-07-20T15:12:14Z")

</div>

hello @Marco !

Thanks a lot for your solution which answered to half of my problem

Since i’m a total noob to Zola and i can’t seem to find a way to solve the other hald and show **X posts only**

i tried `{% for post in post_section.pages limit:3 %}` (i figured since [it works on Jekyll](https://stackoverflow.com/questions/17890493/how-can-i-show-just-the-most-recent-post-on-my-home-page-with-jekyll#17892476) it was worth a try^^) but that was a fail ☹

i can’t find the solution in the doc, i’m not even sure how to look for it but i sure did…

thanks a lot if you can help me \o/

---

<div class="post-metadata">

**Author:** ![Frokost](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/frokost/32/800_2.png) [@Frokost](https://zola.discourse.group/u/Frokost)\
**Post date:** [July 20, 2022, 3:24pm UTC](https://zola.discourse.group/t/pull-feature-post-to-home-page/829/9 "2022-07-20T15:24:35Z")

</div>

Well i guess the law of “ask the question and then the second after you find the answer” striked again :

for those interested i used the [solution proposed as a workaround on github](https://github.com/getzola/zola/issues/147)

```auto
{% set limit = 3 %}
{% for page in subsection.pages %}
   {% if loop.index <= limit %}
       {{ page.title }}
       {% if not loop.index == limit %},{% endif %}
    {% endif %}
{% endfor %}

```
