Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Parsing shop.name to json when it includes an & (ampersand)

Parsing shop.name to json when it includes an & (ampersand)

david_thehub
Shopify Partner
2 0 1

Good night,

 

How should I parse to json a shop.name including an "&"? Right now, for a store titled  "Test & Store", the code {{ shop.name | json }} returns something like "Test \u0026amp; Store".

 

This is causing problems with Google indexation.

 

One solution would be using "and" instead of "&", but I am afraid it could cause SEO problems. Another solution, is using the store name hardcoded instead of the code "shop.name | json", but if in the future there is change in the shop name, it will need to be searched and updated.

 

Any advice?

 

Thanks in advance,

Reply 1 (1)

Wayne_Foster
Shopify Partner
21 0 2

For anyone else that lands here - I came across the same issue when parsing products titles for inclusion in a dataLayer for GTM.  Got around it by replacing the parsed ampersand with just the html code;

 

{{ line_item.product.title | json | replace: "\u0026amp;", "\u0026" }}

So in your instance, maybe try:

 

{{ shop.name | json | replace: "\u0026amp;", "\u0026" }}