Simple Silverlight SEO with ASP.Net and XSLT


A common practice with Rich Interactive Applications (RIAs) is to expose the text as hidden DIV section in on the same page as the Silverlight control.  I have crafted a page with a Silverlight application that has a unique word on it that is picked up by Google’s search engine.  When search crawlers see the page, they don’t see the Silverlight XAML but they do see the XHTML that is generated by transforming the XAML into XHTML.  Using the ASP.Net <asp:Xml> element and specifying an XSL Transformation that does this translation:

<div id=”SLHost”>

    <asp:Xml ID=”XHTML” runat=”server” DocumentSource=”seo.xaml” TransformSource=”XAML2XHTML.xsltEnableViewState=”False”/>

    <script type=”text/javascript”>

        createSilverlight();

    </script>

</div>

Try using this technique for your Silverlight applications running ASP.Net.  Here is how the content is transformed:

  • <Canvas> elements are turned into <div> tags
  • <TextElement> elements are turned into <div> tags with the text inside
  • <Run> elements are turned into <span> tags
  • <Image> elements are turned into <img> tags
  • <MediElement> elements are turned into <a href> hyperlinks.

It doesn’t produce pretty XHTML but search engines don’t care about that.  take a look at the XSLT transform and see how simple it actually is.  Using this technique, when the XAML changes, the plain-text XHTML content changes as well.

Comments (18)

  1. Synergist says:

    The technique described in my previous post will work for Silverlight solutions that generate XAML on

  2. Erik says:

    Michael,

    Thanks for this great blog post.  

    I’d like to get your thoughts on using the technique you’ve presented here to take an existing WPF SmartClient (Windows) app and process, server-side, the XAML and emit it as an XHTML browser-based app for an open Internet audience (people who may not have the Silverlight plugin)?

    Exuse my newbie-ness (to WPF/Silverlight), but if this is a viable approach, aren’t there going to be implications for both client-side scripting and server-side event handling/postbacks/etc.?

    Thanks in advance!

  3. Synergist says:

    Erik,

    That approach would work great.  You just have to find a format that’s rich enough to support the various clients format that you want to render in. You might want to come to this webinar on a related topic: http://blogs.msdn.com/synergist/archive/2007/10/24/upcoming-webinar-better-online-documentation-creating-wpf-flowdocuments-from-word-2007.aspx

    The basic approach is that the XML format is great becauase it is easily transformable.  As long as the data is well-formed XML it can be transformed and adapted to other XML formats like XAML, Open XML, XHTML, or Silverlight XAML.

    Michael

  4. Erik says:

    Michael,

    Thanks for the response.  But, what about interactivity of the app?  I can see how rendering of the XAML to XHTML using this method for the purpose of SEO would work well.

    The purpose rendering it as a cross-browser "app" (with interactivity) would at least require the ability for callbacks to services, etc.  I’d guess that would have to be templated as well (and have to use something like AJAX), and would get complicated quickly.  What are you thoughts given this purpose?

    Thanks in advance.

  5. John M says:

    Hi,

    I created a similar test on <a href="http://www.silverlightseo.net&quot; title="Silverlight SEO">http://www.silverlightseo.net</a&gt; just before the new year. Yes it has Silverlight SEO in the domain name and it does have an inbound link with the keywords from my blog posting which can affect the results. More info about the approach I took is on my <a href="http://weblogs.asp.net/jmandia/archive/2008/01/04/silverlight-seo-search-engine-optimisation-optimization.aspx">blog posting</a>.

    John

  6. Anonymous says:

    by Don Burnett Well it’s been a bit since I posted I had been working really hard and somehow I ended up getting pneumonia. So I have been taking a break, but several exciting things happened that I figure I should tell you about. Expression Studio Version

  7. SliverlightSEODemo

    http://xmldocs.net/seo/ SimpleSilverlightSEOwithASP.NetandXSLT

    http…

  8. tim Kadom says:

    From what i understand, google does not index hidden divs.  http://www.seroundtable.com/archives/002971.html

    A bunch of flex guys tried a similar approach and verfied that google skips the hidden divs.

  9. tim Kadom says:

    From what i understand, google does not index hidden divs.  http://www.seroundtable.com/archives/002971.html

    A bunch of flex guys tried a similar approach and verfied that google skips the hidden divs.

  10. Synergist says:

    Tim,

    You’re right. but in this case the divs are not hidden, they’re just replaced with the Silverlight if the browser has Silverlight installed.

    Michael

  11. Thanks for everyone who came out to the Toronto and Montreal TechDays. The three Silverlight sessions

  12. Thanks for everyone who came out to the Toronto and Montreal TechDays. The three Silverlight sessions

  13. brianna102 says:

    Hello this is Brianna visiting first time to this site  and find it very interesting. I really like to join it.and really want to continue the discussion with this site..

    ——-

    Brianna

    <a href="http://www.widecircles.com&quot; rel="dofollow">SEO</a>

  14. Allan. says:

    用ASP.NET XSLT实现Silverlight SEO

  15. J. says:

    Thanks for the great post!

    Just thought I would mention, the namespace in Silverlight 2 has been changed.

    For anyone trying this with Silverlight 2, make sure the namespace in the xaml matches the xsl namespace.

    The change was from

    xmlns="http://schemas.microsoft.com/client/2007&quot;

    to     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;

Skip to main content