how do you edit tags in the DotNetNuke CMS?
it generates lots of meta tags and has an ID element for each meta tag which is not in the w3c recommendations. Ive looked at SEO optimization articles and it says not to have any other meta tags other than for the keywords and name -- is this true?
Meta tags when i view the source code:
<meta id="MetaKeywords" name="KEYWORDS" content="naruto, fan, forums, DotNetNuke,DNN" />
<meta id="MetaCopyright" name="COPYRIGHT" content="Copyright naruto"/>
<meta id="MetaGenerator" name="GENERATOR" content="DotNetNuke " />
<meta id="MetaAuthor" name="AUTHOR" content="naruto" />
<meta name="RESOURCE-TYPE" content="DOCUMENT" />
<meta name="DISTRIBUTION" content="GLOBAL" />
<meta name="REVISIT-AFTER" content="1 DAYS" />
<meta> tags always go inside the <head> element, and are typically used to specify character set, page description, keywords, author of the document, and viewport settings. Metadata will not be displayed on the page, but is machine parsable.
Unfortunately, there is not a straightforward/supported way to remove most of those meta
tags in DNN. You'll need to do some degree of altering the core code and/or making assumptions that certain IDs will stay the same. For example, you can remove/replace with robots meta tag by putting code like this in the skin:
private void Page_PreRender(object sender, EventArgs e) {
var metaRobots = Page.FindControl("MetaRobots") as HtmlMeta;
if (metaRobots != null) {
metaRobots.Visible = false;
}
}
You can delete them from Default.aspx using any text editor, however this can prove troublesome as you'll probably rewrite it with next update, so I'd recommend you append this simple C# snippet to the bottom of your skin .ascx file
<script runat="server">
protected override void OnLoad(EventArgs e)
{
var metatagsToKeep = new[] { "Content-Type", "Content-Script-Type", "Content-Style-Type", "Refresh", "DESCRIPTION", "KEYWORDS", "COPYRIGHT", "GENERATOR", "AUTHOR", "RESOURCE-TYPE", "DISTRIBUTION", "ROBOTS", "REVISIT-AFTER", "RATING", "PAGE-ENTER" };
var metaTags = (from headerControl in this.Page.Header.Controls.OfType<HtmlControl>() let cont = headerControl where !metatagsToKeep.Contains(cont.Attributes["name"]) && !metatagsToKeep.Contains(cont.Attributes["http-equiv"]) select headerControl).Cast<Control>().ToList();
foreach (var metaTag in metaTags)
{
this.Page.Header.Controls.Remove(metaTag);
}
}
</script>
In the controlsToKeep array just remove ones you want to remove and you are done. In case DNN adds some new you'd want (which is unlikely), you'll have to add them to the list. Or you can reverse logic and create array for metatagsToDelete, your call :).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With