I have created a widget text box that contains just an HTML tag.
<h1>Some heading</h1>
and then insert this widget to a CMS page with url: "cms_page_link".
When I hit the CMS page URL, for example: 
http://example.com/cms_page_link/
the page show that widget content just as string with quoted:
"<h1>Some heading</h1>"
not the HTML element as I expected:
Some heading
Have anyway to get HTML tag as normal?
- 
 Can you post your code lines of widget here?Khoa Truong– Khoa Truong2017年12月25日 10:26:43 +00:00Commented Dec 25, 2017 at 10:26
- 
 Ah none code, I'm just create widget via admindiv– div2017年12月25日 10:54:56 +00:00Commented Dec 25, 2017 at 10:54
2 Answers 2
Solution - "CMS Static Block" widget
- Go to - Content -> Blocks, create a new block, write- <h1>Some heading</h1>in it and save.
- Go to the CMS page you want to edit, insert the widget CMS Static Block, in the widget select the block you just created, then save the page and it will work. 
Solution - Template
Write codes like this {{block class="Magento\Framework\View\Element\Template" name="blockname" template="Vendor_Module::test.phtml" my_vars="123,456"}} in your page. Create the template file in you module, you could use variable in it, it is a flexible way. You could get some info from How to retrieve variable from CMS page in Magento 2 
- 
 Oh, I known this approach, but I am wanna to use a widget, not CMS blocksdiv– div2017年12月26日 03:11:57 +00:00Commented Dec 26, 2017 at 3:11
- 
 @viethung But it is indeed a widget typeCMS Static Block, it doesn't have obvious difference withcreated a widget text box that contains just an HTML tag. If you doesn't like this way, you could use template, not widget. I will add it in the answer.Key Shang– Key Shang2017年12月26日 03:29:21 +00:00Commented Dec 26, 2017 at 3:29
You should use in the template htmlspecialchars_decode($variable);