How to modify default header tags
Even if you create a blank template, and / or select "Do not inherit any content" option in template properties, the rendered html code still contains some html tags which you did not define. Why and how can it be changed?
In Kentico CMS, when using Portal engine development model, some important tags are added into the head section of every rendered page automatically, as there is some important data which needs to be rendered no matter what template you are using.
Usual content of this automatically rendered code is this:
…
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-script-type" content="text/javascript" />
<link href="/ CMSPages/GetResource.ashx?stylesheetname=<siteCodeName>" type="text/css" rel="stylesheet"/>
<link href="/ favicon.ico" type="image/x-icon" rel="shortcut icon"/>
<link href="/ favicon.ico" type="image/x-icon" rel="icon"/>
…
If you want to change it somehow, there is nothing easier than navigating to <project folder>\CMSPages\PortalTemplate.aspx.cs file and change the content of the “HeaderTags” string variable.
For example, let’s say I want to remove the whole "<meta http-equiv="pragma" content="no-cache" />" line from the code above.
It can be done like this:
…
// Init the header tags
tags.Text = HeaderTags;
tags.Text = tags.Text.Replace("<meta http-equiv=\"pragma\" content=\"no-cache\" />", "");
…
When using ASPX templates instead of Portal engine pages, you can use the same approach, however you need to do it in the code-behind of the particular master page you are using, e.g. <project folder>/CMSTemplates/BlankAspx/Blank.master.cs.
-rm-
Applies to: Kentico CMS 6.0