Reputation: 13
I have my brand name or shop name added to all my URL's via the following statement which is found in the theme.liquid file. I want to exclude all pages that are blogs or articles. This would mean no shop name on those URL's, which is this pipe and code.
| {{ shop.name }}
Original Code
{%- capture seo_title -%}
{%- if template == 'search' and search.performed == true -%}
{{ 'general.search.heading' | t: count: search.results_count }}: {{ 'general.search.results_with_count' | t: terms: search.terms, count: search.results_count }}
{%- else -%}
{{ page_title }}
{%- endif -%}
{%- if current_tags -%}
{%- assign meta_tags = current_tags | join: ', ' -%} – {{ 'general.meta.tags' | t: tags: meta_tags -}}
{%- endif -%}
{%- if current_page != 1 -%}
– {{ 'general.meta.page' | t: page: current_page }}
{%- endif -%}
{%- assign escaped_page_title = page_title | escape -%}
{%- unless escaped_page_title contains shop.name -%}
| {{ shop.name }}
{%- endunless -%}
{%- endcapture -%}
<title>{{ seo_title | strip }}</title>
I have been trying to place another if statement around the following but I have had no luck yet.
{%- assign escaped_page_title = page_title | escape -%}
{%- unless escaped_page_title contains shop.name -%}
| {{ shop.name }}
{%- endunless -%}
This is the code that I have tried, is there a better way to do this as I can't quite get it to work.
Attempted Code
{%- capture seo_title -%}
{%- if template == 'search' and search.performed == true -%}
{{ 'general.search.heading' | t: count: search.results_count }}: {{ 'general.search.results_with_count' | t: terms: search.terms, count: search.results_count }}
{%- else -%}
{{ page_title }}
{%- endif -%}
{%- if current_tags -%}
{%- assign meta_tags = current_tags | join: ', ' -%} – {{ 'general.meta.tags' | t: tags: meta_tags -}}
{%- endif -%}
{%- if current_page != 1 -%}
– {{ 'general.meta.page' | t: page: current_page }}
{%- endif -%}
{%- if (template == "blog" or template == "article") and current_tags contains '_NOINDEX' -%}
{%- assign escaped_page_title = page_title | escape -%}
{%- unless escaped_page_title contains shop.name -%}
{%- endunless -%}
{%- else -%}
{%- assign escaped_page_title = page_title | escape -%}
{%- unless escaped_page_title contains shop.name -%}
| {{ shop.name }}
{%- endunless -%}
{%- endif -%}
{%- endcapture -%}
<title>{{ seo_title | strip }}</title>
Upvotes: 1
Views: 1900
Reputation: 2559
You can just use the following:
{%- unless escaped_page_title contains shop.name or template == 'blog' or template == 'article' -%}
| {{ shop.name }}
{%- endunless -%}
You were close, but you cannot use parentheses to group Liquid condition operators.
Upvotes: 1