0

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?

| improve this question | | | | |
  • 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 '15 at 23:16
0

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
| improve this answer | | | | |
0

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}
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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