kumbi1 kumbi1 - 1 month ago 23
Twig Question

double-quotes making problems in google

I used the replace function in

twig
to remove the unwanted pieces of the function and it is working perfectly except it still contains the double-quotes.
This is the code:

{% set htmlheader = sd_htmltitle(false) %}
<title>
{{ htmlheader|replace({'brand:': "", "websitesub:" : "", "websitecategory:" : "", '"' : ''}) }}
</title>


As you can see, I tried replacing the quotation marks, but they still appear in the title. Do you have a solution, or perhaps a better way to handle the situation if applicable? Everything else is getting removed properly.

Thanks!

Answer

You should add a \ before the quotation marks. So try this:

   {{ htmlheader|replace({'brand:': "", "websitesub:" : "", "websitecategory:" : "", '\"' : ''}) }}

Here a working example

Hope this help