SEOHelper RenderMetaTag does not create a new tag

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 Jahre weitere
I am not sure if this is by design but currently if you try to use RenderMetaTag to CREATE a new meta tag it doesn't do it.

I updated my local function as follows

using System.Linq;

public static void RenderMetaTag(Page page, string name,
            string content, bool overwriteExisting)
        {
            if (page == null || page.Header == null)
                return;

            if (content == null)
                content = string.Empty;
            HtmlMeta control = page.Header.Controls.OfType<HtmlMeta>().FirstOrDefault(meta => string.Equals(meta.Name, name,StringComparison.OrdinalIgnoreCase));
            if (control == null)
            {
                control = new HtmlMeta();
                control.Name = name;
                control.Content = content;
                page.Header.Controls.Add(control);
            }
            else
            {
                if (overwriteExisting || String.IsNullOrEmpty(control.Content))
                {
                    control.Content = content;
                }
            }
}
13 Jahre weitere
Hi,

I'm also not sure, but suppose if you will dynamicly add HtmlMeta to the page header it can be placed bellow some css or js maybe. It's bad for SEO, keywords and description better to place at the top of html code.
13 Jahre weitere
I needed to be able to add robots noindex nofollow tags.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.