---
title: "Why is HTML being escaped when using Drupal tokens?"
date: "2020-10-02T15:45:21+00:00"
summary: "Discover why HTML is escaped in Drupal tokens and learn how to handle it effectively. Get expert tips on using hook_tokens_alter() to allow HTML in specific tokens, enhancing your Site Studio components."
image:
type: "article"
url: "/drupal-starter-kits/add-ons/site-studio/help/64531-why-html-being-escaped-when-using-drupal-tokens"
id: "8347276d-f8b8-45e4-9142-8ecb3eaf3e17"
---

HTML is escaped when using Drupal tokens in Site studio as a security measure, this follows Drupal core.

If HTML is input into something like a node title field and then a token such as \[node:title\] is used within a Site studio component the HTML inside the field will be escaped and render as a string. This follows Drupal core.

If you require the HTML to not be escaped for specific tokens you can use the below hook\_tokens\_alter() in your custom code:

This example alters the menu link title value token to allow HTML.

    /**
     * Implements hook_tokens_alter().
     **/
    function cohesion_tokens_alter(array &$replacements, array $context,\Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata) {
      if(isset($replacements['[menu_link_content:title:value]'])) {
        $replacements['[menu_link_content:title:value]'] = \Drupal\Core\Render\Markup::create(Drupal\Component\Utility\Html::decodeEntities($replacements['[menu_link_content:title:value]']));
      }
    }