How to use and extend page metatags in the SiteSeeker Search Integration for EPiServer

9/4/2013

When developing a website with SiteSeeker using SiteSeeker as your search engine, its important that you provide SiteSeeker with as much information as possible. This information can be provided through metatags. When the site is being crawled you want this information to be visible to the crawler, however not visible to the end user of your website.

The SiteSeeker integration module now ships with an built-in component for EpiServer.This article describes how to use and extend the metatag component SiteSeeker.EPiServer.PageMetaDataHandler.

Use the metatags helper to generate HTML

The metatags helper displays meta elements that contain data for standard EPiServer properties, such as title, ID, categories and (optionally) access control list.

Rendering example for EPiServer

<head>
  <% var helpers = HtmlHelperFactory.Get<XHtmlHelpers>("exempleSearchIndex");%>
  <%=helpers.MetaTags(CurrentPage) %>
</head>

Example of HTML output

An example of the html rendered if you have set your useragent to SiteSeekerCrawler/1.0 or programmatically set the IsSiteSeekerCrawler to true as per above example.

<meta content="Start" name="EPI.Title" />
<meta content="2012-01-01T12:35:37+02:00" name="EPI.Revised" />
<meta content="2012-01-01T12:35:54+02:00" name="EPI.Modified" />
<meta content="2007-09-27T14:33:00+02:00" name="EPI.Published" />
<meta content="3" name="EPI.ID" />
<meta content="" name="EPI.Author" />
<meta content="en" name="EPI.Language" />
<meta content="" name="EPI.Category" />

Enabling access control

In order to have SiteSeeker access control hits, access control must be enabled for the corresponding server in SiteSeeker Admin. Furthermore, you should enable printing of access control lists in the metadata handler. In web.config, add a new section within the siteseeker section like so:

  <siteseeker autoConfigure="true">
    <searchIndices>
      <add name="exampleSearchIndex" displayName="the example index" url="http://siteseeker-knowledgebase.siteseeker.se/ws/siteseeker-knowledgebase/" userName="ws" password="gnus5/dopier" />
    </searchIndices>
  <components>
      <add name="metaTags" implementation="SiteSeeker.EPiServer.PageMetaDataHandler,SiteSeeker.EPiServer" service="SiteSeeker.Extensions.IMetaTagHandler,SiteSeeker">
        <parameters>
          <add name="PrintACL" value="true"></add>
        </parameters>
      </add>
    </components>
  </siteseeker>

Advanced configuration of PageMetaDataHandler

By default a component named EPiServerMetatagHandler has been registered and renders metatags based on the most common configuration in EPiServer.

You can change the configuration via your web.config. Here is an example of how the configuration could look like:

<siteseeker>
    <searchIndices>
      <add name="exampleSearchIndex" displayName="the example index" url="http://siteseeker-knowledgebase.siteseeker.se/ws/siteseeker-knowledgebase" userName="ws" password="gnus5/dopier"></add>
    </searchIndices>
    <components>
      <add name="test" implementation="SiteSeeker.EPiServer.PageMetaDataHandler,SiteSeeker.EPiServer" service="SiteSeeker.Extensions.IMetaTagHandler,SiteSeeker">
        <parameters>
          <add name="CategoryPropertyName" value="fromconfig"></add>
          <add name="UseBuiltInEpiServerCategories" value="true"></add>
          <add name="UseDynamicPropertyForCategories" value="true"></add>
          <add name="CrawlerUserName" value ="theuser"></add>
        </parameters>
      </add>
    </components>
  </siteseeker>

The above configuration shows that a component named PageMetaDataHandler implements the SiteSeeker interface IMetaTagHandler and the component has some parameters which we have conifgured to use specific values e.g setting UseBuiltInEpiServerCategories to true.

Below is a list of the properties that can be configured.

Meta tag properties

Is properties which contains the value which will be rendered in the meta tag elements name attribute.

TitleMetaTagName EPI.Title
RevisedMetaTagName EPI.Revised
ModifiedMetaTagName EPI.Modified
PublishedMetaTagName EPI.Published
IdMetaTagName EPI.ID
AuthorMetaTagName EPI.Author
LanguageMetaTagName EPI.Language
CategoryMetaTagName EPI.Category
ACLMetaTagName EPI.ACL

EPiServer properties

The EPiServer Page type's property name containing the value which will be rendered in the metatag element's value attribute.

TitlePropertyName Heading
DescriptionPropertyName MetaDescription
CategoryPropertyName PageCategory
KeywordsPropertyName MetaKeywords
AuthorPropertyName MetaAuthor

Configuration properties

UseDynamicPropertyForCategories false Indicates whether to use the CategoryPropertyName to render the category metatag.
UseBuiltInEpiServerCategories false Indicates whether built-in categories should be used to render category metatag.
IncludeParentInTitle false include the page name of the parent page in the title for this page
CrawlerUserName Username of Crawler used to authenticate the visiting crawler.
PrintACL false printing the ACL metatag.
DateFormat yyyy-MM-ddTHH:mm:sszzz The format of the dates which are rendered.

Debugging

Note: The metags will only be rendered if the user agent is set to 'SiteSeekerCrawler/1.0'. For debugging purposes you can add this line to force rendering:

<% helpers.IsSiteSeekerCrawler = true; %>

Register your own implementation

Its possible to register your own implementation of the SiteSeeker interface IMetatagHandler by implementing this interface yourself or inheriting from EPiServerMetatagHandler and override or extend the metatags.

Below is an example showing how to change the default behaviour for Title metatag and add your own tag "CustomTag".

<components>
      <add name="test" implementation="MyNamespace.MyCustomHandler,MyAssembly"    service="SiteSeeker.Extensions.IMetaTagHandler,SiteSeeker">
      </add>
 </components>