# Creating a blog category button

**URL:** <https://community.hubspot.com/t/creating-a-blog-category-button/106847>\
**Category:** CMS Development\
**Tags:** professional\
**Created:** [May 9, 2024, 7:24pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847 "2024-05-09T19:24:04Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![SlimSr2003](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/slimsr2003/32/73373_2.png) [@SlimSr2003](https://community.hubspot.com/u/SlimSr2003)\
**Post date:** [May 9, 2024, 7:24pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847/1 "2024-05-09T19:24:04Z")

</div>

Hi,

I am trying to create a button on the blog index page that will take the user to a specific catagory (tag) page.

Here is the code I have right now:

\<div class=“article\_list\_cta”\>  
\<a class=“black-white-button” style=“color: white” href=“{{ blog\_tag\_url(“Media\_Coverage”, module.blog\_post\_tag) }}”\>View All Coverage\</a\>  
\</div\>

I think it is a simple fix but I have been beating my head aginst the wall to figure it out so any help would be greatly appreciated.

Thanks

Scott

---

<div class="post-metadata">

**Author:** ![SlimSr2003](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/slimsr2003/32/73373_2.png) [@SlimSr2003](https://community.hubspot.com/u/SlimSr2003)\
**Post date:** [May 9, 2024, 9:43pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847/2 "2024-05-09T21:43:44Z")

</div>

After thinking about this I think it is becasue it is not in the default blog. It is in a second blog with a different name. How do I change the code to include the blog indicator?

---

<div class="post-metadata">

**Author:** ![Humashankar](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/humashankar/32/30856_2.png) [@Humashankar](https://community.hubspot.com/u/Humashankar)\
**Post date:** [May 9, 2024, 9:55pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847/3 "2024-05-09T21:55:27Z")

</div>

Hi @SlimSr2003

By ensuring that you’ve already created the category (tag) named “Media\_Coverage” in your HubSpot blog settings

Try this code and see if you could able to fix this:

\<div class=“article\_list\_cta”\>

\<a class=“black-white-button” style=“color: white” href=“{{ blog\_category\_url(“Media\_Coverage”) }}”\>View All Coverage\</a\>

\</div\>

The changes what i recommend is all about the below one - for your reference:

- Use the {{ blog\_category\_url(“Media\_Coverage”) }} template tag instead. This tag specifically builds a URL for a blog category (tag) based on its name.
- Remove module.blog\_post\_tag from the code. This part seems unnecessary for generating the category URL.

**Hope this helps - Happy to help further!!**  
**Thank you very much and have a great one!**  
**Warm regards**

---

<div class="post-metadata">

**Author:** ![SlimSr2003](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/slimsr2003/32/73373_2.png) [@SlimSr2003](https://community.hubspot.com/u/SlimSr2003)\
**Post date:** [May 13, 2024, 12:16pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847/4 "2024-05-13T12:16:05Z")

</div>

Hi Humashankar,

Thanks for the reply. The consul is giving me an error when I put that code into that line.

 ![SlimSr2003_0-1715602344166.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/1/9/1916e4fe5f8fd8f521b2555e9c9326f4004548cc.png)

Any other ideas?

With the previous code here is the error it was prodcuing;

![SlimSr2003_1-1715602502190.png](https://d2qpr2jzcazej7.cloudfront.net/optimized/3X/7/d/7d766bd3863ceb87a2130c9ff4a704abc13c2aa6_2_690x34.png)

You can view the page here: [Newsroom](https://45821948.hs-sites.com/newsroom) if this helps.

Any additioanl help you can provide would be greatly apprciated.

Thanks

Scott

---

<div class="post-metadata">

**Author:** ![Humashankar](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/humashankar/32/30856_2.png) [@Humashankar](https://community.hubspot.com/u/Humashankar)\
**Post date:** [May 13, 2024, 1:22pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847/5 "2024-05-13T13:22:55Z")

</div>

Hi @SlimSr2003

It appears to be two separate issues,

1) The error message “Invalid Blog ID ‘Press release’ passed to blog\_tag\_URL” suggests that you may be using an incorrect parameter with the {{ blog\_tag\_url }} template tag, which we previously advised against using.

Resolution - Simply remove {{ blog\_tag\_url }} entirely from your code. As we discussed earlier, the correct tag for generating category URLs is {{ blog\_category\_url(“Media\_Coverage”) }}

2) error message “blog\_tag\_url(): tag not found by slug: null” indicates that the {{ blog\_tag\_url }} code (if you still have it) is attempting to find a non-existent tag.

Resolution - Verify that the category (tag) named “Media\_Coverage” is correctly set up in your HubSpot blog settings.

- If you’re using a different category name, simply update the code with the correct name: {{ blog\_category\_url(“YourCategoryName”) }}

**Hope this helps - Happy to help further!!**  
**Thank you very much and have a great one!**  
**Warm regards**

---

<div class="post-metadata">

**Author:** ![SlimSr2003](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/slimsr2003/32/73373_2.png) [@SlimSr2003](https://community.hubspot.com/u/SlimSr2003)\
**Post date:** [May 14, 2024, 1:57pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847/6 "2024-05-14T13:57:12Z")

</div>

Hi Humashankar,

I have replaced both of the code sections that are trying to generate the Blog URL with your code.

Here is the first section:

\<div class=“release\_list\_cta”\>  
\<a class=“black-white-button” style=“color: white” href=“{{ blog\_category\_url(“Press\_Release”) }}”\>View All Releases\</a\>  
\</div\>

Here is the second section:

\<div class=“article\_list\_cta”\>  
\<a class=“black-white-button” style=“color: white” href=“{{ blog\_category\_url(“Media\_Coverage”) }}”\>View All Coverage\</a\>  
\</div\>

I am still getting an error:

Could not resolve function ‘blog\_category\_url’

![SlimSr2003_0-1715694725954.png](https://d2qpr2jzcazej7.cloudfront.net/optimized/3X/6/d/6d44a37e244f945b81b13d40c4187ebb1abc10d1_2_690x55.png)

I have verified that both the Press\_Release and the Media\_Coverage tags are in the Newsroom blog.

 ![SlimSr2003_1-1715694803826.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/0/07cb00d8d4514ea675b313730a85dbed9f72e25b.png)

So I am at a loss as to what is happening. Is there somewhere else in the code of the page that isn’t calling the Newsroom blog? I really don’t know.

Here is the page code:

\<!--  
templateType: blog\_listing  
isAvailableForNewContent: true  
label: Boilerplate - newsroom listing  
screenshotPath: ../images/template-previews/blog-index.png  
--\>  
{% set template\_css = “../../css/templates/blog.css” %}  
{% extends “./layouts/base.html” %}

{% block body %}  
\<div class=“column-container”\>  
{# ----------------------- Header ---------------------- #}  
\<div class=“blog\_header”\>  
{% module “module\_171526232513644” path=“/Filter-Labs-Website/modules/Text Centered Image Tight Left and Right”, label=“Text Centered Image Tight Left and Right” %}  
\</div\>  
{# ----------------------- Newsroom Featured Articles ---------------------- #}

\<div style=“margin-top: 20px;”\>  
{% module “module\_171527297876861” path=“/Filter-Labs-Website/modules/Recent Newsroom Post Box”, label=“Recent Newsroom Post Box” %}  
\</div\>  
\</div\>  
{# ----------------------- Article and Release Lists ---------------------- #}  
\<div class=“full\_width\_container\_grey”\>  
\<div class=“column-container”\>  
\<div class=“article\_release\_container”\>  
\<div class=“article\_release\_subhead”\>  
\<h3\>  
Articles and Press Releases  
\</h3\>  
\</div\>  
\<div class=“article\_release\_list\_container”\>  
\<div class=“release\_list\_containter”\>  
\<div class=“release\_list\_header”\>  
\<h4\>  
FilterLabs’ Press Releasees  
\</h4\>  
\</div\>  
\<div class=“release\_list”\>  
\<div\>  
{% set my\_tag\_posts = blog\_recent\_topic\_posts(‘default’, ‘Press\_Release’, 10) %}  
\<ul\>  
{% for post in my\_tag\_posts %}  
\<li style=“line-height: 2rem;”\>\<a href=“{{ post.absolute\_url }}”\>{{ post.title }}\</a\>\</li\>  
{% endfor %}  
\</ul\>  
\</div\>  
\</div\>  
\<div class=“release\_list\_cta”\>  
\<a class=“black-white-button” style=“color: white” href=“{{ blog\_category\_url(“Press\_Release”) }}”\>View All Releases\</a\>  
\</div\>  
\</div\>  
\<div class=“article\_list\_container”\>  
\<div class=“article\_list\_header”\>  
\<h4\>  
FilterLabs in the News  
\</h4\>  
\</div\>  
\<div class=“article\_list”\>  
\<div\>  
{% set my\_tag\_posts = blog\_recent\_topic\_posts(‘default’, ‘Media\_Coverage’, 10) %}  
\<ul\>  
{% for post in my\_tag\_posts %}  
\<li style=“line-height: 2rem;”\>\<a href=“{{ post.absolute\_url }}”\>{{ post.title }}\</a\>\</li\>  
{% endfor %}  
\</ul\>  
\</div\>  
\</div\>  
\<div class=“article\_list\_cta”\>  
\<a class=“black-white-button” style=“color: white” href=“{{ blog\_category\_url(“Media\_Coverage”) }}”\>View All Coverage\</a\>  
\</div\>  
\</div\>  
\</div\>  
\</div\>  
\</div\>  
\</div\>

{# ----------------------- News Story Source Request ---------------------- #}

\<div class=“column-container”\>  
\<div\>  
{% module “module\_17152861606712” path=“/Filter-Labs-Website/modules/Text Left w Image Form Right”, label=“Text Left w Image Form Right” %}  
\</div\>

{# ----------------------- Events Section ---------------------- #}  
\<div class=“events\_section\_container”\>  
\<div\>  
{% module “module\_171529012646220” path=“/Filter-Labs-Website/modules/Centered Text”, label=“Centered Text” %}  
\</div\>  
\<div\>  
{% module “module\_171528993868617” path=“/Filter-Labs-Website/modules/Event Image and Text Description”, label=“Event Image and Text Description” %}  
\</div\>  
\<div class=“event\_list\_cta\_container”\>  
\<div class=“event\_list\_cta”\>  
\<a class=“black-white-button” style=“color: white” href=“{{ blog\_tag\_url(“Event”, module.blog\_post\_tag) }}”\>View More Events\</a\>  
\</div\>  
\</div\>  
\</div\>

\</div\>

{% endblock body %}

Sorry for the back and forth but I appreciate your help.

Thanks

Scott

---

<div class="post-metadata">

**Author:** ![Humashankar](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/humashankar/32/30856_2.png) [@Humashankar](https://community.hubspot.com/u/Humashankar)\
**Post date:** [May 14, 2024, 3:45pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847/7 "2024-05-14T15:45:54Z")

</div>

Hi @SlimSr2003

Thanks for the outcome, happy to help - let me get some other options in some time.

Regards

---

<div class="post-metadata">

**Author:** ![SlimSr2003](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/slimsr2003/32/73373_2.png) [@SlimSr2003](https://community.hubspot.com/u/SlimSr2003)\
**Post date:** [May 16, 2024, 3:13pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847/8 "2024-05-16T15:13:50Z")

</div>

Hi Humashankar,

I figured out a work around for this. What I did was just put a button to a specific page that has a module that lists out the specific blog tag posts. It’s not exactly what I thought I wanted but I actually like it better. Thanks for your time time and consideration on helping me with this.

Scott

---

<div class="post-metadata">

**Author:** ![Humashankar](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/humashankar/32/30856_2.png) [@Humashankar](https://community.hubspot.com/u/Humashankar)\
**Post date:** [May 16, 2024, 5:19pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847/9 "2024-05-16T17:19:02Z")

</div>

Hi @SlimSr2003

Well done on finding a workaround that suits your needs! Thanks for letting me know and for your appreciation.

Regards

---

<div class="post-metadata">

**Author:** ![Humashankar](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/humashankar/32/30856_2.png) [@Humashankar](https://community.hubspot.com/u/Humashankar)\
**Post date:** [May 20, 2024, 9:24pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847/10 "2024-05-20T21:24:09Z")

</div>

Hi @SlimSr2003

Thanks for sharing your workaround!

Am glad you were able to find a solution that works for you.

Regards

---

<div class="post-metadata">

**Author:** ![Humashankar](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/humashankar/32/30856_2.png) [@Humashankar](https://community.hubspot.com/u/Humashankar)\
**Post date:** [May 14, 2024, 4:04pm UTC](https://community.hubspot.com/t/creating-a-blog-category-button/106847/11 "2024-05-14T16:04:36Z")

</div>

Hi @SlimSr2003

First lets go with this step and will see, whether we can move one level higher.

The error message (Could not resolve function 'blog\_category\_url) signals that the HubL template engine might not be able to recognize the blog\_category\_url function within the context of your template.

- Can you check blog\_category\_url function is defined or not in the current template or a parent template that is included and it might not be accessible?
- Check the presence and try to include the necessary HubL libraries or functions blog\_category\_url which might not be available
- Look for a parent template - layouts/base.html, that might be extending a core HubSpot template that defines blog\_category\_url and also ensure the inheritance chain is correct, If blog\_category\_url is indeed defined in a parent template

**Regards**
