Decode the special characters in page title of product

Decode the special characters in page title of product

HarshiManju
Shopify Partner
1 0 0

Hi, 


I would need to decode the special characters of my page title. The product page is perfectly fine already. However, I would need for page title.
Example: 

Input: Combat By test™ Example
Expected Output:  Combat By test™ Example

 

I've used the below code to decode the page title. However, it doesn't work.

 

page: theme.liquid

<title>{{ page_title | url_decode }}</title>

 

 

Thanks

Reply 1 (1)

PaulNewton
Shopify Partner
7722 678 1626

If these titles are being output for <html> content the entities should just work.

 

url_decode is for percent encoded characters for usage with URLS.

And not for html-entities for usage in <html> tags ;which oddly liquid does NOT support.

https://developer.mozilla.org/en-US/docs/Glossary/Entity 

https://shopify.dev/api/liquid/filters#url_decode 

https://github.com/Shopify/liquid/issues/859 

 

If you must convert a lot of strings like this using liquid you'll basically have to make a big case/when statement doing string matching to return the desired string output. If performance minded be sure to test that snippet with the liquid profiler extension.

https://shopify.dev/themes/tools/theme-inspector 

 

Though you may be better off changing strings at the source depending on what is trying to be achieved. 

 

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org