-
The technique described in my previous post will work for Silverlight solutions that generate XAML on the server side as well as solutions that have multiple static XAML files that are composited at runtime:
<div id="SLHost">
<asp:Xml ID="XHTML" runat="server" DocumentSource="seo.xaml" TransformSource="XAML2XHTML.xslt" EnableViewState="False"/>
<!-- XAML that is generated by the server: -->
<asp:Xml ID="XHTML" runat="server" DocumentSource="Xaml.aspx?id=page1" TransformSource="XAML2XHTML.xslt" EnableViewState="False"/>
<!-- XAML that is in many parts but composited at runtime: -->
<asp:Xml ID="XHTML" runat="server" DocumentSource="details.xaml" TransformSource="XAML2XHTML.xslt" EnableViewState="False"/>
<asp:Xml ID="XHTML" runat="server" DocumentSource="about.xaml" TransformSource="XAML2XHTML.xslt" EnableViewState="False"/>
<script type="text/javascript">
createSilverlight();
</script>
</div>
But there are circumstance where you would want to have a SEO-friendly HTML that is more specific to your Silverlight application. My colleague Nikhil Kolthari, wrote in his blog about other techniques for SEO in Silverlight where the application server would write out an alternative HTML version that is specific to his slide show application.
-
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.xslt" EnableViewState="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.