Just starting with plugin development. I modified the code from pluginfactory.io for a custom tag:

public function navHTML()
    $result = '<h2>Hello again</h2>';
    return $result;

and I am getting output. The issue is the html tags are being converted to alt characters. Here is the actual source of my index page:


IT looks like Craft or Twig is converting the tags to alt characters. I need to create an unordered list html using the plugin. How do I prevent Craft or Twig from converting the HTML to alt characters?

1 Answer 1


You need to make sure that you're returning the raw version of the HTML.

In Craft 2, it looks like this...

return TemplateHelper::getRaw($result);

In Craft 3, it looks like this...

return Template::raw($result);

If you're doing this in Craft 3, you need to also be sure that you are loading the Template helper class at the top:

use craft\helpers\Template;
  • Maybe it's worth noting: you can also use/access that function inside your template with {{ html|raw }} Mar 26, 2018 at 7:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.