Whenever I use an apostrophe in a meta description the browser prints the code as '. Is there a way to prevent this?

These are coming trough a custom module that builds out the page.

  • How does it get there in the first place? Module Metatags? Custom module? Twig? – leymannx Aug 29 '19 at 4:52
  • @leymannx, added a bit more info above but I'm new to Drupal so not really sure how it works. – MeltingDog Aug 29 '19 at 5:03
  • Show code that builds/fetches the tag names... – No Sssweat Aug 29 '19 at 7:06

When using apostrophe in a taxonomy it is displayed as &amp#039; in the html-tittle of the page

The problem could be fixed by disabling the module "Metatag: Views" or updating the metatag.inc accordingly: replacing the check_plain() by filter_xss()

class DrupalTitleMetaTag extends DrupalTextMetaTag {

  public function getElement(array $options = array()) {
    $element = array();
    $value = filter_xss($this->getValue($options));
    $element['#attached']['metatag_set_preprocess_variable'][] = array('html', 'head_title', $value);
    $element['#attached']['metatag_set_preprocess_variable'][] = array('html', 'head_array', array('title' => $value));
    return $element;
| improve this answer | |
  • Are you suggesting to hack the Metatag module? – leymannx Sep 3 '19 at 11:41

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.