compare page title inside if condition

200 views Asked by At

Im trying to include a new meta tag into my business catalyst blog. Below is my structure

Main blog http://mywebsite.com/blog

Tags http://mywebsite.com/blog/tags/sometag

category http://mywebsite.com/blog/category/somecat

post http://mywebsite.com/blog/posttitle

All of the above links have a common page title except for the post page. So based on the title, so if the title is "blog" then include the meta tag

 {% if module_pagetitle == 'Blog' -%}
        <p>include tag{module_pagetitle}</p>
         {% else -%}
        <p>dont include tag {module_pagetitle}</p>
       {% endif -%}

When i include the above code to the Overall blog layout template, the page title is always empty

I also tried

{tag_pagetitle}

It doesnt seem to be working.

Can some please let me know how can i get this condition working ?

Thanks

2

There are 2 answers

0
Neido On

I believe you'll have to add into the Module Layouts > overall blog layout

<head>  
<title>{module_pagetitle}</title>
</head>

That should negate the need for anything else as all /blog pages that are not posts will have a title of the name of the blog, then all posts will have the post name as the title.

0
Alex Steinberg On

Try to assign the page title to a variable using Liquid's Capture and then perform the comparison against that variable. For example,

{% capture titleToCompare -%}
    {module_pagetitle}
{% endcapture -%}