Meta Elements

Meta Elements

Meta Elements (Meta Tags)

  • Used to provide structured metadata about a Web page
  • Multiple <meta> elements with different attributes are often used on the same page
  • Must be placed as tags in the head section of an HTML or XHTML document
  • Used to specify page description, keywords and any other metadata not provided through the other head elements and attributes
  • Not guaranteed to help search rankings with crawler-based search engines
    • Can help to control how web pages are described by some search engines
    • Can be used to prevent pages from being indexed

Meta Description Tag

  • An important tag for your pages because it gives you some control with various search crawlers
  • In Sitecore, use code to populate the META DESCRIPTION from a field on the item instead of placing a static description on the layout 
    • The META DESCRIPTION should be unique for each rendered page
    • Take the first sentence or two of body copy from your page and use that for the meta description content

HTML5 Meta Element Attributes

  • Charset is used to indicate the character set of the document
  • Content
  • Http-equiv is used to emulate the HTTP header
  • Name is used to embed metadata
  • Scheme

Other Meta Element Attributes

  • Description provides a concise explanation of a Web page's content
  • Language tells search engines what natural language the website is written in (e.g. English), as opposed to the coding language (e.g. HTML)

Meta Element Examples

  • <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  • <meta http-equiv="content-language" content="en" />
  • <meta http-equiv="reply-to" content="" />
  • <meta name="keywords" content="Sitecore,CMS,content,management,resources,API" />
  • <meta name="language" content="English" />
  • <meta name="resource-type" content="document" />
  • <meta name="revisit-after" content="15 days" />
  • <meta name="classification" content="Software" />
  • <meta name="description" content="Provides information on using Sitecore CMS to create and manage web sites, and documents using the Sitecore API to create custom solutions" />
  • <meta name="distribution" content="Global" />
  • <meta name="rating" content="Safe For Kids" />
  • <meta name="copyright" content="The Inside Corner, Inc." />
  • <meta name="author" content="Craig Nelson" />
  • <meta name="doc-type" content="Web Page" />

Dynamic Meta Elements in .NET Framework 4.0

  • Each page of your site should have a unique meta-title and meta-description
  • Create a field named 'abstract' in the template inherited by all "web-page" items on your site
  • Populate the 'abstract' field for each "web-page" item with a sentence or two about the content on that page
  • Add the following code to the code behind file of your site layout (.aspx.cs file)
  • using Sitecore.Web.UI.WebControls;
  • private void Page_Load(object sender, System.EventArgs e)
  • {
  • if (!IsPostBack)
  • {
  • Page.Title= FieldRenderer.Render(item, "menu title");
  • Page.MetaDescription = FieldRenderer.Render(item, "abstract");
  • Page.MetaKeywords = FieldRenderer.Render(item, "abstract");
  • }
  • }

Static Meta Elements