In creating page titles based on URL segments (for list pages), we have utilized conditionals that point to the segment urls for conditional inclusion. HOWEVER when the page source is viewed (and the page is indexed), the conditionals that are not met leave extra spaces within the Meta Title text.

Chocolate {if segment_2 == ""} Cookie{/if}{if segment_2 !=  "any"} {segment_2_category_name}{/if}{if segment_3 != "any"} {segment_3_category_name}{/if}{if segment_4!= "any"} {segment_4_category_name}{/if} Recipes

Results in Meta title (the dots are extra spaces): Chocolate Cookie.....Recipes

The extra spaces should not be included BUT if the other segments are filled in, the spacing is correct:

Chocolate Raisin Caramel Cookies

Why does the unmet conditional leave a space? - AND how do we get rid of it?

  • The parse engine does that. It's not great. Is your code actually like you're showing it (as one line code, and the conditionals don't have line breaks)?
    – jrothafer
    Jul 21, 2015 at 23:16

2 Answers 2


Try this:

Chocolate {if segment_2 == ""} Cookie{if:elseif segment_2 !=  "any"} {segment_2_category_name}{if:elseif segment_3 != "any"} {segment_3_category_name}{if:elseif segment_4!= "any"} {segment_4_category_name}{/if} Recipes

The trick is to add the space only inside the conditionals, for example:

Chocolate{if segment_2 == ""} Cookie{/if}{if segment_2 !=  "any"} {segment_2_category_name}{/if}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.