# Creating listing page by topic

**URL:** <https://community.hubspot.com/t/creating-listing-page-by-topic/8368>\
**Category:** CMS Development\
**Created:** [April 3, 2018, 7:38pm UTC](https://community.hubspot.com/t/creating-listing-page-by-topic/8368 "2018-04-03T19:38:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![josephLayden](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/josephlayden/32/68653_2.png) [@josephLayden](https://community.hubspot.com/u/josephLayden)\
**Post date:** [April 3, 2018, 7:38pm UTC](https://community.hubspot.com/t/creating-listing-page-by-topic/8368/1 "2018-04-03T19:38:44Z")

</div>

I am trying to create a custom module that prints out a list of absolute links to individual blog posts. Each topic will have its own listing page. For example, there are fifty states in the USA. I create a listing page for each state and expect any blog post tagged will populate on their respective state listing pages. Also, if a post has multiple tags it should populate on all of the appropriate pages. In the analogy of the fifty states, if I write a blog post and tag it California and Ohio, the listing page for CA and OH will both have an absolute link to back to the post. I would like to sort each state listing page by date as well. Currently I am able to print all of the tags but not sort them into individual listing pages.

{% set posts = blog\_tags(5664168304, 50) %}  
{% for post in posts %}

{% if post.name == ‘California’ %}  
\<div class=“state-post-listing”\>  
\<ul\>  
\<li\>\<a href=“{{post.absolute\_url}}”\>{{ post.name }}\</a\>\</li\>  
\</ul\>  
\</div\>  
{% endif %}

{% endfor %}

---

<div class="post-metadata">

**Author:** ![roisinkirby](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@roisinkirby](https://community.hubspot.com/u/roisinkirby)\
**Post date:** [April 25, 2018, 1:26pm UTC](https://community.hubspot.com/t/creating-listing-page-by-topic/8368/2 "2018-04-25T13:26:39Z")

</div>

Hey @josephLayden if possible could you share a link to the page/preview page your are working on and links to th epages you want to feature?

[@AJLaPorte\_diagr](https://community.hubspot.com/t5/user/viewprofilepage/user-id/202) what would you advise in this case?

---

<div class="post-metadata">

**Author:** ![josephLayden](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/josephlayden/32/68653_2.png) [@josephLayden](https://community.hubspot.com/u/josephLayden)\
**Post date:** [April 25, 2018, 1:45pm UTC](https://community.hubspot.com/t/creating-listing-page-by-topic/8368/3 "2018-04-25T13:45:39Z")

</div>

[https://community.hubspot.com/t5/Content-Design-Questions/Filter-HubDB-by-row-using-Hubl/m-p/184942#M5520](https://community.hubspot.com/t5/Content-Design-Questions/Filter-HubDB-by-row-using-Hubl/m-p/184942#M5520)

---

<div class="post-metadata">

**Author:** ![AJLaPorte\_diagr](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/ajlaporte_diagr/32/24548_2.png) [@AJLaPorte\_diagr](https://community.hubspot.com/u/AJLaPorte_diagr)\
**Post date:** [April 25, 2018, 4:35pm UTC](https://community.hubspot.com/t/creating-listing-page-by-topic/8368/4 "2018-04-25T16:35:31Z")

</div>

Hi @josephLayden,

Quick question, is there a reason you are doing this in a custom module and not using the normal topic listing pages? For example, [your-blog-domain.com/topic/ohio](http://your-blog-domain.com/topic/ohio)

You can modify the blog listing template to show these types of content listings instead of using a custom module. It would look like this:

```auto
{% for content in contents %}
 {% if not simple_list_page %}
 {% if topic %}
 <a href="{{content.absolute_url}}">{{ content.name }}</a>
 {% else %}
 // Your normal look for blog listing here
 {% endif %}
 {% endif %}
{% endfor %}

```

This essentially is saying if it’s a topic listing page, show this content otherwise show the normal layout. You could make it more specific to the topic instead so it can be:

```auto
{% set stateList = ['ohio', 'california', 'illinois', ....] %}
{% for content in contents %}
 {% if not simple_list_page %}
 {% if topic in stateList %}
 <a href="{{content.absolute_url}}">{{ content.name }}</a>
 {% else %}
 // Your normal look for blog listing and other topics not in stateList here
 {% endif %}
 {% endif %}
{% endfor %}

```

Hopefully this helps a bit and can be a different way to accomplish this without needing to maintain both your blog and a HubDB table

-AJ

---

<div class="post-metadata">

**Author:** ![josephLayden](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/josephlayden/32/68653_2.png) [@josephLayden](https://community.hubspot.com/u/josephLayden)\
**Post date:** [April 25, 2018, 4:41pm UTC](https://community.hubspot.com/t/creating-listing-page-by-topic/8368/5 "2018-04-25T16:41:53Z")

</div>

For some reason the tagging is not working correctly for the built in plugin. For example, I tagged this post with the states (WI, IN, IL) \> [March 13, 2018 | Vigorous Job Market Expected for Chicago-Naperville-Joliet, IL-IN-WI MSA](https://go.manpowergroup.com/press/march-13-2018-vigorous-job-market-expected-for-chicago-naperville-joliet-il-in-wi-msa-1)

However, the module renders incorrect tags instead.

---

<div class="post-metadata">

**Author:** ![Prabu](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/prabu/32/34870_2.png) [@Prabu](https://community.hubspot.com/u/Prabu)\
**Post date:** [October 16, 2019, 10:32am UTC](https://community.hubspot.com/t/creating-listing-page-by-topic/8368/6 "2019-10-16T10:32:29Z")

</div>

There is having any option to show all the **saved tags** in blog page?

Not this !!! (bcaz i need to show all the saved tags not only the blog topics.)

\<div class=“topic-list”\>  
\<h3\>Topics\</h3\>  
{% set my\_topics = blog\_topics(‘default’, limit=250) %}  
\<ul\>  
{% for item in my\_topics %}  
\<li\>\<a href=“{{ group.absolute\_url }}/topic/{{item.slug}}”\>{{ item }}\</a\>\</li\>  
{% endfor %}  
\</ul\>  
\</div\>
