LiveEn
LiveEn

Reputation: 3253

compare page title inside if condition

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

Upvotes: 0

Views: 206

Answers (2)

Alex Steinberg
Alex Steinberg

Reputation: 1466

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 -%}

Upvotes: 1

Neido
Neido

Reputation: 181

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.

Upvotes: 0

Related Questions