Reputation: 1
I'm using the Foundry theme and on the /products
page. I have links to the different categories of products. These take you to /category/______
. There is a <h1>
heading, which has a default of value Shop
. I want the value to represent the current category. I tried the following code, but the heading was just blank.
<h1>
...
{% elsif page.full_url contains "category/" %}
{% for category in categories.all %}
{% if page.full_url contains {{ category.permalink }} %}{{ category.name }}{% endif %}
{% endfor %}
...
</h1>
Examples:
page.full_url
returns https://website/category/wall-hangings
category.permalink
returns wall-hangings
I also tried a method using:
{{ page.full_url | remove: "https://website/category" | replace: "-" " " | capitalize }}
However, the replace
method doesn't insert spaces.
Upvotes: 0
Views: 72
Reputation: 1
I overcomplicated my original approach. Using {{ page.name }}
returns the category name, so using this in the heading tag worked.
Upvotes: 0