# Getting blog listing data from a module

**URL:** <https://community.hubspot.com/t/getting-blog-listing-data-from-a-module/116993>\
**Category:** CMS Development\
**Tags:** local-development, professional\
**Created:** [September 24, 2024, 7:07pm UTC](https://community.hubspot.com/t/getting-blog-listing-data-from-a-module/116993 "2024-09-24T19:07:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DEsteva](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/desteva/32/2232_2.png) [@DEsteva](https://community.hubspot.com/u/DEsteva)\
**Post date:** [September 24, 2024, 7:07pm UTC](https://community.hubspot.com/t/getting-blog-listing-data-from-a-module/116993/1 "2024-09-24T19:07:52Z")

</div>

Hello guys! How are you?

I’m working on getting data from a Blog Listing Module to a Webpage, actually the module if working smoothly on the Blog Templates but i can’t make it work on Website Pages. On the Blogs its works like you can see on the attatched photo.

 ![Screenshot 2024-09-24 at 15.58.46.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/3X/5/7/57cd56ed04b705048d3ae08f70869ed4019b0d33.jpeg)

But on the website pages but it doesn’t show. As you can see in the next photo. It should be available on the section marked with a red rectangle.

 ![Screenshot 2024-09-24 at 16.03.30.jpg](https://d2qpr2jzcazej7.cloudfront.net/original/2X/a/ac4f120e264659864619c7a85747fa24e456deb4.jpeg)

The layout that is not being viewed is the next one:

```lia-code-sample
<section class="hs-blog-post-listing hs-blog-post-listing--{{ layout }}">
 {% for content in contents %}

 {# Blog listing article #}

 <article
 class="hs-blog-post-listing __post hs-blog-post-listing__ post--{{ layout }} {{ "hs-blog-post-listing__post--{{ columns }}" if has_columns }}"
 {% if has_full_image and content.featured_image %}
 style="background-image: url({{ content.featured_image }});"
 {% endif %}
 aria-label="{{ module.default_text.full_blog_post_summary_text }}"
 >

 {# Adds a wrapper for an overlay if full image is enabled #}

 {% if has_full_image and content.featured_image %}
 <div class="hs-blog-post-listing__post-inner-wrapper">
 {% endif %}

 {# Post image #}

 {% if not has_alternate_image or loop.index is not divisibleby 2 %}
 {{ post_image("left") }}
 {% elif has_alternate_image and loop.index is divisibleby 2 %}
 {{ post_image("right") }}
 {% endif %}

 {# Article content #}

 {{ post_content() }}

 {# Adds a wrapper for an overlay if full image is enabled #}

 {% if has_full_image and content.featured_image %}
 </div>
 {% endif %}

 </article>
 {% endfor %}

</section>

```

Thanks guys!

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [September 24, 2024, 7:40pm UTC](https://community.hubspot.com/t/getting-blog-listing-data-from-a-module/116993/2 "2024-09-24T19:40:27Z")

</div>

Hi @DEsteva ,

The `contents` [variable](https://developers.hubspot.com/docs/cms/hubl/variables#blog-variables) is only available on the blog listing page, so you can’t loop through it on a website page.

In that case, you can use the [blog\_recent\_posts](https://developers.hubspot.com/docs/cms/hubl/functions#blog-recent-posts) function on a website page to retrieve your blog posts. You can pass ‘default’ as the first parameter to retrieve the primary blog or pass the ID of a specific blog.

You could try updating your code to something like this:

```lia-code-sample
{% set posts = contents ? contents : blog_recent_posts("default", 200) %}

<section class="hs-blog-post-listing hs-blog-post-listing--{{ layout }}">
 {% for content in posts %}

 {# Blog listing article #}

 <article
 class="hs-blog-post-listing __post hs-blog-post-listing__ post--{{ layout }} {{ "hs-blog-post-listing__post--{{ columns }}" if has_columns }}"
 {% if has_full_image and content.featured_image %}
 style="background-image: url({{ content.featured_image }});"
 {% endif %}
 aria-label="{{ module.default_text.full_blog_post_summary_text }}"
 >

 {# Adds a wrapper for an overlay if full image is enabled #}

 {% if has_full_image and content.featured_image %}
 <div class="hs-blog-post-listing__post-inner-wrapper">
 {% endif %}

 {# Post image #}

 {% if not has_alternate_image or loop.index is not divisibleby 2 %}
 {{ post_image("left") }}
 {% elif has_alternate_image and loop.index is divisibleby 2 %}
 {{ post_image("right") }}
 {% endif %}

 {# Article content #}

 {{ post_content() }}

 {# Adds a wrapper for an overlay if full image is enabled #}

 {% if has_full_image and content.featured_image %}
 </div>
 {% endif %}

 </article>
 {% endfor %}

</section>

```
