Please upgrade your web browser now. Internet Explorer 6 is no longer supported.
Zac Smith
SharePoint, WSS and MOSS development.

While many SharePoint'ers are over in Vegas eagerly awaiting the start of the 2009 SharePoint Conference, the rest of back in reality enduring the hardships of plain old SharePoint 2007...

Over the past couple of years, the number of SharePoint built websites has grown significantly. But how do all of these sites stack up from a technical SEO perspective? Lets have a look using the new IIS 7.0 SEO Toolkit to analyze our site: www.trinkit.co.nz.

Here is the output after running the tool over our website:

 OK cool, lots of errors! Now what do they mean and what can we do about it?

1. The page contains multiple canonical formats
This means that there are multiple addresses that can be used to access the pages of our website. For example, take the home page; we could browse to this page in the following ways:
http://www.trinkit.co.nz/pages/home.aspx
http://www.trinkit.co.nz/Pages/home.aspx (capitalization)
http://www.trinkit.co.nz/pages/home.aspx (no www)

The effect of this is that search engines will potentially spread the ranking over the different URLs rather than aggregating it for the one page. Now search engines are fairly clever and it should work out that there is only one page to rank. Not taking any chances here is a method you can use to fix this (IIS 7 only).

2. The page contains unnecessary redirects
This is because of the infamous 302 rewrite issue.When you type a URL like www.trinkit.co.nz, SharePoint will perform a 302 (temporary) redirect to www.trinkit.co.nz/pages/default.aspx. This is not ideal as search engines are not as keen on following 302 redirects, they prefer 301s (permanent). There is no ideal way of fixing this but here are a couple of options:
- Use IIS7 redirect rules
- Using an HTTPModule

3. The description is missing (Not SharePoint specific)
This is really obvious, we are missing the meta description tag. The meta description tag is normally used for your search engine result page (SERP) listing and is a key factor in determining relevancy. While we are on the topic, don't bother with the meta keywords tag. The big search engines have been ignoring this since about 2002.

4. The page contains broken hyperlinks (Not SharePoint specific)
Another obvious content issue. Broken hyperlinks are said by some to affect page rankings. In theory search engines will favour sites and pages that have relevant, up-to-date content and broken links are sign of poorly maintained page. This is tough to keep a handle on with blogs that have large amounts of outgoing links, but there are tools available that can help.

5. through to 7. are not SharePoint specific issues and there are heaps of great resources around that address these so I won't cover that here.

8. The URL is linked using different casing
As mentioned in item 1, search engines are case sensitive. In an ideal world all of your urls and all the links to them would be lowercase, with dashes used to separate words. The navigation controls in SharePoint always redirect to a first letter capitalized 'Pages' and what is worse is the tendency for URL's to occasionlly be loaded in upper case. A technique to address this issue is discussed in this blog post.

9. & 10. are not SharePoint specific

11. The page contains a large amount of script code
SharePoint does have a habit of including an awful lot of additional javascript. However I do think it's a little bit unfair for it to be reported in this case as I have removed most of it. Plenty of the javascript that gets loaded is only needed for authenticated authors and the associated rich editing controls. There are a few simple techniques to remove this and doing so can give you a great performance boost.

12. This page contains invalid markup
It's pretty commonly known that SharePoint isn't exactly standards friendly. Search engines will have an easier time processing the contents of your page if it is easily parsable. Now this doesn't mean that it has to be XHTML 1.1 Strict compliant. It just means that all the tags are closed and are not mismatched, which is a lot easier to achieve than XHTML standards. As WCAG 2.0 has the same requirements you can use a WCAG 2.0 validator to test this.

One other thing that does not seem to covered by the IIS SEO Toolkit:

13. There is no XML sitemap defined
An XML sitemap tells the search engine where are all the pages you want crawled are, it is not made to be human readable. For a quick and easy way to get this setup check Waldek's sitemap generator.

Note that this was done on a slightly older version of the site, and a few of these issues have already been fixed.

The SEO tool is still in Beta and seems to be a little over zealous in the number of issues it reports, but it is already providing some really useful results.
Of course, nothing beats having really great original content that naturally generates healthy back links. Fixing these technical issues is really just a way of maximising that hard work and there is certainly nothing wrong with that!

Categories: MOSS, SEO, SharePoint, Trinkit, WCM

We've been pretty busy over the last 6 months working on a variety of projects and I would like to share a few of these with you today. Some of the projects have been for clients, some for friends; a few have been big, most have been small. All of them were fun to make.

Environment Canterbury
Environment Canterbury is the regional council working with the people of Canterbury to manage the region's land, water and air. This site was released just a week ago and was built using SharePoint Server 2007 (of course!). Was a super fun project and we are really happy with the final result.


Kinloch Golf Club

The Kinloch Club was voted one of the Top 10 new golf courses in the world for 2007 by the prestigious U.S. Travel and Leisure golf magazine - making it the only course outside of North America to be included in that Top 10.
This site was built using asp.net and CMS functionality was provided by Umbraco (http://umbraco.org/).


New Zealand Garden Sheds

New Zealands top supplier of high quality steel garden sheds. This is a PHP site built on WordPress.


Good Golfing

The website and blog of Renee Fowler, a great golf coach based in Wellington. This is also a PHP site built on WordPress.




Chilli Jam

A podcast blog for cutting edge dance music. Yet another PHP site built on WordPress.

Categories: Trinkit, WCM

Configuring search on a public facing Web Content Management (WCM) site is quite a different task compared with your typical SharePoint intranet. Searching over internal content largely works out of the box; setting up a few content sources and basic scopes is usually enough to satisfy most users.

With a public website we want a simpler more ‘bing/google’ like search experience. The method of search is a basic search keyword phrase input and the power of the search resides in the indexing of content. We do not want to rely on a user’s ability to construct complicated search terms. Everybody can use it, and use it effectively.

What follows from here is a basic guide for setting up SharePoint search on an anonymously accessed SharePoint publishing site. This assumes a bit of experience configuring search, but if you don't take a look at this TechNet webcast on installing and configuring search in SharePoint Server 2007.

Creating Scopes

Creating scopes is the most important step in configuring public search. There are usually a number of resource files such as CSS, JavaScript, XSL and images as well as objects like user profiles that you wouldn’t want showing up in your search results. However we do want to be able to search over all of our document libraries, inlcuding aspx pages. So our first step is to create a scope that will return all pages and documents which we can create like this:

Public Search Scope Example

A search using this scope will return anything that is in the content source “Local Office SharePoint Server sites” AND (the content is a publishing page OR the content is a document). Note the brackets used in this statement.

As you can see the rule behaviour is being used to create logical conditions. The logic of the rules can be applied as follows:

  • Include = OR
  • Require = AND
  • Exclude = AND NOT

The ‘contentclass’ property specifies what type the indexed item is and will be automatically available for any content item in SharePoint. The two types that we are usually concerned with in a public site are:

  • STS_ListItem_850 (Publishing Pages)
  • STS_ListItem_DocumentLibrary (Documents)

Check out this post from Dan Attis for a complete list of contentclass values.

Tip

I would recommend against allowing list items in your search scopes. The basic reason for this is that to view a list item you need to browse to the display form (/Forms/DispForm.aspx). Problem is this should be locked down by the Form Lock down feature. Unfortunately it is common for lists to be used to store content for your public web site; for example when using WSS collaboration features such as blogs, wikis and discussion lists. At the end of the day the collaboration and publishing features in SharePoint don’t play very nicely together. When making design decisions for a SharePoint based solution and the question comes up - “Should we put this content in a simple list or create aspx pages?”, you should consider whether you want the content to be searchable or not.

Scope Examples

What if we wanted to create a scope that returned everything under a specific web? In this example I have added folder rule that will include all results in or beneath the 'about-us' site:

Public Scope for a web

 

What if we had a shared server environment that hosted multiple websites? In this example I have added a domain rule so that any results for my site 'http://trinkit' will be returned:

Public Scope for a Site

If you don’t know how to create scopes than have look at this help page from microsoft office online.

Tip

When indexing document libraries make sure that the documents are of a file type known to SharePoint, otherwise SharePoint will crawl the document as a list item and use the form display page rather than the actual document itself. Check out the filter pack from Microsoft if you want to add additional file types.

Creating a Simple, Deployable Layout

Armed with our public search scopes we already have enough information to return the right results. The next step is to create a simple search page to display search results.

When you create a search centre using the out-of-the-box search site template, you get a whole bunch of features that just aren’t that well suited to a public facing scenario (RSS Feeds, Alerts, Advanced Search). My recommendation is to take a light weight minimal approach - why use a whole search centre when a single results page will do it? Creating a single page layout that is part of an easily deployable SharePoint solution is often the cleanest way to go.

Web Parts

Web Part zones often cause issues when it comes to repeatable deployment and they add additional HTML bloat. If you are wanting the simplest HTML output possible then web part zones should be avoided.When it comes down to it we only really need a page layout with a few basic web parts – SearchBoxEx, CoreResultsWebPart and the SearchPagingWebPart.

Here is an example of using the CoreResultsWebPart in a search page layout without web part zone.

<Search:CoreResultsWebPart runat="server" 
    ID="SearchResults" 
    ShowActionLinks="True" 
    Scope="All Pages and Documents"  
    HighestResultPage="1000" 
    DuplicatesRemoved="True" 
    DisplayDiscoveredDefinition="True" 
    ShowSearchResults="True" 
    FrameType="None" 
    NoiseIgnored="True" 
    StemmingEnabled="True" 
    View="Relevance" 
    QueryNumber="Query1" 
    SentencesInSummary="3" 
    ResultsPerPage="10" 
    DateFormat="DateOnly" 
    DisplayAlertMeLink="False" 
    DisplayRSSLink="False" 
    RelevanceView="True" 
    WebPart="true">
    <XslLink>/XSL/CoreSearchResults.xsl</XslLink>        
    <SelectColumns>
        <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <Columns>
                <Column Name="WorkId"/>
                <Column Name="Rank"/>
                <Column Name="Title"/>
                <Column Name="HitHighlightedProperties"/>
                <Column Name="Size"/>
                <Column Name="Path"/>
                <Column Name="Description"/>
                <Column Name="PictureThumbnailURL"/>
                <Column Name="SiteName"/>
                <Column Name="CollapsingStatus"/>
                <Column Name="HitHighlightedSummary"/>                
                <Column Name="ContentClass"/>
                <Column Name="IsDocument"/>
                <Column Name="Write"/>
                <Column Name="Author"/>
                <Column Name="ContentType"/>
            </Columns>
        </root>
    </SelectColumns>        
</Search:CoreResultsWebPart>

The other web parts can be added to the page layout in the same way.

Tip

Make sure search.js is inlcuded in a custom search page layout as it is needed for logging search statistics: 

<asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <SharePoint:ScriptLink ID="ScriptLink1" name="search.js" runat="server"/>
</asp:Content>

  

Additional Branding Considerations

The majority of the branding is quite easy due to the core search results web part using an XSL transformation to style the results. Unfortunately the other web parts will require tedious battling with overriding of SharePoint’s CSS properties. Not ideal but you can still get it looking pretty decent if you know what you are doing.

For full control of the HTML structure and styling you would need to create a bespoke solution that used the search SQL Syntax API that comes with MOSS. This is also the only solution if you require some advanced sorting or filtering functionality. This isn't overly difficult, but it's a tough one to explain to the business owner that is forking out for SharePoint.

So what about advanced search? I think we’ll leave that one for another day.

I hope this post gives you a few ideas and some "best practices" on you can go about creating a decent search solution for you public SharePoint website.

Good luck!

Categories: Development, MOSS, Search, SharePoint, WCM
Recently there have been a few key improvements to the STSADM backup command which I have found to make life a lot easier (and safer!).

After installing Service Pack 2 and running the backup command you will notice a few subtle, but important changes:


Previously it was a best practice to set the site being backed up to read only using the setsitelock command. This is something that I am guessing 95% of people never did. And who can blame them as it wasn't made terribly obvious. Fortunately the backup command now automatically sets this and lazy admins can have peace of mind.

The April CU also provided an important update to how backup and restore works, particularly with publishing sites. In SharePoint, the actual page layout aspx files are stored with some hardcoded metadata which includes the url of the site they belong to. Previously when performing a backup & restore to different farms with different URLs this could cause issues. Import/Export does not have this problem as the page layouts are recreated in the target site. The backup command has now been updated to fix this issue and this method of migrating content between farms is now supported. Note that the June CU is now available and supersedes the April CU.

So why would you want to use backup/restore over import/export to migrate content anyway?
If you commonly use the SPSiteDataQuery class, ContentQuery webpart or the DataView webpart you rely on GUID references to lists for query commands. By default, import/export assigns new GUIDS to any lists that are migrated which will upset the queries that rely on them. Using backup/restore was an easy way to avoid this issue.

Of course it was fairly easy to write some import code using the object model and retain the GUID values. And if you still want to use import/export that is the way to go.
Categories: MOSS, WCM, Development, Infrastructure, SharePoint, WSS
Sales, marketing, project managers and even IT managers always seem to latch onto the concept of building a web part to provide custom functionality in SharePoint. I’m always being asked to create a web part for various tasks which just complicates things. In reality 95% of the time a web control will do the job just fine, or better yet a user control.
 
A web part usually dictates that you will be dynamically creating asp.net controls at runtime or writing HTML tags in managed code. Both of these techniques are pretty horrible and provide no separation between logic and presentation. There are many examples of this on CodePlex.
 
A user control has a few key advantages over web parts:
  • Easier development: User controls provide a design time surface and allows easier HTML integration
  • Easier deployment: There are less steps required to make a user control available in a SharePoint site
  • Less unwanted HTML: Web parts and the web part framework include additional HTML bloat that decreases accessibility
That said there are a few good reasons why you would want to build a web part:
  • Reusability: If the component is going to be used in multiple pages with different configurations
  • Admin control: Web part properties provide a convenient way for admins to manage settings
  • Collaboration: Where users or content authors want to be able to add web parts to their own pages
If you decide that you do need a web part, I would still advocate using a user control. You can either use something like SmartPart, or preferably just embed it yourself as it’s a very simple task. By embedding a user control to a web part in a 1-1 relationship, you have the opportunity to use web part properties as well as providing the best user experience.
 
The same theory can be applied to field controls. Another option when creating web parts is to use XSLT to control the display. I believe this is a great approach as it provides good separation between logic and presentation, makes it easier for integrators and promotes accessible HTML.
 
I guess web parts just sound cooler?
 
Resources:
Categories: Development, MOSS, SharePoint, WSS, WCM

The details of the first ever NZ SharePoint conference have been finalised.

This will be the New Zealand conference to learn about SharePoint 2007 with expert local and international speakers presenting on topics that will help you understand and succeed with your SharePoint implementations and add real value to your organization and businesses.”

I’m quite excited to be presenting a session on Web Standards and accessiblity. This is something I’m quite passionate about and have done a fair amount of research on over the last couple of years. I plan to focus on public websites and the basics of accessibility and W3C compliance.

I wrote a blog post on this almost exactly two years ago. Some of the techniques are a little outdated now but I’ll be addressing that in my session.

The actual session brief is something along the lines of .....

Title: Web Standards, SharePoint and Accessibility - Yes you can.
Description: Web Standards, Accessibility, SharePoint. Many people are under the impression that these words don’t go together. In this session Zac will demonstrate how a public web site in SharePoint can be both accessible and adhere to W3C recommendations. A number of available tools will be evaluated including AKS 2.0 and ARF. Zac will also provide many tips and techniques for anyone looking to build a web standard compliant site in SharePoint.

Attendees should have a basic understanding of SharePoint Publishing Features and NZ Web Standards.

Session Type: Technical
Session Level: 300
Time:  4:15 – 5.15
Location: Chamber Room 1

The conference is pretty exciting stuff for NZ’s SharePoint community  - so don’t miss it!

Categories: Community, SharePoint, WCM, Accessibility

Tech-Ed New Zealand 2008

by Zac Smith 29-Aug-08, 0 Comments
Tech-Ed New Zealand is just around the corner, and I'm really looking forward to it. This year I'm involved in co-presenting two sessions:
 
 
OFC301 - Creating Content Centric Publishing Sites with MOSS 2007.

Mark Orange and Zac Smith
Tuesday 2nd September
3:45 - 5:00 pm
NZRoom 3 SkyCity

This session focuses on using the Web Content Management features of Microsoft Office SharePoint Server 2007 to build rich content web sites. Learn how users can create web pages and manage the publishing process using core SharePoint features. Then walk through some code and demos using Microsoft Visual Studio and SharePoint Designer to understand the SharePoint web page model and to learn some good software development processes when developing web sites on Microsoft Office SharePoint Server 2007.
 

OFC303 - Tools and techniques for productive and effective SharePoint development.

Matt Smith and Zac Smith
Wednesday 3rd September
3:45 - 5:00 pm
NZ Room 3, SkyCity

In this deep-dive, demo-oriented session for developers, we look at tools and techniques for maximising productivity and effectiveness when customising SharePoint. Topics will include: productive build cycles, development environment optimisation, best practices, “I didn’t know SharePoint designer could do that!”, innovative use of Powershell and working effectively in teams.  Community tools and extensions that assist developer effectiveness will also be covered in detail in our section: don’t be a tool, be a better developer through tools!
 

If you can't make it along on the day, DPE New Zealand are running ‘Tech.Ed Live’, an online version of Tech.Ed, to complement the offline event. It’s a way to share some of the content and general Tech.Ed goodness with the unfortunate souls who couldn’t get tickets.
Check it out here: www.techedlive.co.nz

Hope to see ya'll there!
 
 
Tech-Ed 2008
Categories: Community, Development, MOSS, SharePoint, WCM, WSS
A while back I blogged about how you could use the SPSecurityTrimmedControl to manage the display of content based on user permissions. The PermissionsString is where you specify what permissions the user must have to display the content. Until now I wasn't sure what values you could use, and the SDK although much imporoved wasn't exactly forthcoming. While using a reflector I managed to track down the SPBasePermissions enum which reveals all the possible values.
 
And here they are grouped in the same way you would find them in the SharePoint permissions list:
 
List Permissions
 
Site Permissions
EnumeratePermissions
 
Personal Permissions
 
 
And an example of usage if you are reading this and haven't seen the control in action before:
 
<SharePoint:SPSecurityTrimmedControl PermissionsString="AddAndCustomizePages, ManageLists" runat="server"
    <%-- some content here ... %>
</SharePoint:SPSecurityTrimmedControl>
Categories:

This is intended as a pretty high level overview of how you can get MOSS to validate against the W3C XHTML 1.0 recommendation. The aim of this article is not to explain every intricate detail of getting a MOSS site to be XHTML compliant. However it should demonstrate some techniques to get people started and eventually develop better methods of achieving compliance.

Firstly it should be noted that this is really just for public facing publishing sites. In other words we're talking about using just the WCM features of MOSS. You are not going to get your fully featured Intranet to be conformant in the current releases of SharePoint. The reason for this is that SharePoint generates out a lot of non W3C validating code. This is largely due to the richness of many SharePoint features like web parts.
Some of the techniques mentioned in this article are equally applicable to standard ASP.NET sites. So if you're totally unfamiliar with XHTML validation it may be worth having a look at the Microsoft technical article on Building ASP.NET 2.0 Web Sites Using Web Standards. It is also likely that some of these techniques will be unsupported by Microsoft; so use at your own risk.

Web.Config

The first step is to add the conformance configuration setting to your web.config file. This will force certain asp.net controls to only output attributes that comply with XHTML standards.
<xhtmlConformance mode="Strict" />
This is only really important if you are trying to conform to the strict standard. If the setting is omitted the default output for ASP.NET controls is XHTML transitional. I prefer to add the tag in any way to make it explicit. Unfortunately many SharePoint controls are still going to output non-compliant tags.

Master Page Basics

The master page is where you are going to do the majority of the validation work. It really pays to start fresh with the Microsoft minimal master page. You are going to cause yourself a serious amount of pain if you try and tweak one of the out-of-the-box master pages. It is also best to start off using a page that is based on a blank page layout. This will help identify where any validation errors are actually coming from. The first thing to do with the master page is set the doctype to reflect the xhtmlconformance setting. For example if I'm using the strict standard my doctype will be:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
You can also add a few XHTML attributes to the html tag:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

At this stage it is worth performing a W3C validation check to get a feel for the types of errors that need to be fixed.
My initial check yielded a horrifying 232 validation errors, with no content or navigation. Did I say this was going to be easy?
If you scroll through some of the errors you should notice that most of them are to do with invalid attributes. The majority of the errors come from only a few controls; namely the site actions menu and publishing console (referred to as Authoring Controls from here on).

Authoring Controls

These controls aren't as big a problem as they first appear to be. We only really care about W3C compliance for anonymous (public) accessing users. As the authoring console is security trimmed when a normal public user accesses the site the authoring html won't be rendered at all. You can prove this by enabling anonymous access, logging out and then trying to view the page anonymously. Make sure you have checked in and published the master page and layout page or you won't be able to see the changes. The page will only display the welcome control displaying the 'Sign In' message. A quick validation check should show only a dozen or so validation errors. About half of these errors will have something to do with the site actions control. Although it has been removed from the page visually it is still rendering some HTML. There is an easy to solution to this problem; the SPSecurityTrimmedControl. This control allows blocks of content to only render when the user has specified a specified permission set. By wrapping the site action control inside the security trimming control and setting a required permission, the site action control is prevented from rendering any HTML at all.

<SharePoint:SPSecurityTrimmedControl PermissionsString="AddAndCustomizePages" runat="server"
    
<PublishingSiteAction:SiteActionMenu runat="server"/> </SharePoint:SPSecurityTrimmedControl>

Remove/clean non-compliant HTML

Upon making a closer examination of the remaining validation errors it becomes obvious that most of them are to do with poorly declared script tags. Unfortunately these script tags are usually generated by the HtmlForm control so it's not easy to override the output. The one technique that can be applied is to override the Page.Render method and do a bit of tag cleaning. This effectively lets us hijack the HTML rendering process and have a chance to add, modify or remove parts. It does involve writing a bit of inline code in the master page. Assuming that you have set your master page to allow inline code we can add some code similar to the following in the master page.

<script type="text/c#" runat="server">
protected override void Render(HtmlTextWriter writer)
{
 
// extract all html
 
System.IO.StringWriter str = new System.IO.StringWriter();
 
HtmlTextWriter wrt = new HtmlTextWriter(str);

  // render html 
 
base.Render(wrt); 
 
wrt.Close(); 
  string html = str.ToString();

  // find all script tags
 
Regex scriptRegex = new Regex("<script[^>]*");
  MatchCollection scriptMatches = scriptRegex.Matches(html);

  // go through matches in reverse
  for (int i = scriptMatches.Count - 1; i >= 0; i--)
 
{

    // identify script tags with no type attribute 
    if
(scriptMatches[i].ToString().IndexOf("type") < 0)
   

   
  // add type attribute after script opening tag
     
html = html.Insert(scriptMatches[i].Index + 7, " type=\"text/javascript\"");
   
}
  }

  // write the 'clean' html to the page
 
writer.Write(html);
}

</script>

This code block uses some regex matching to find all script tags and add a type attribute to any tags that don't already have one. It is only a partial solution to the script tag problem, more code will need to be written to completely clean the tags.

Note that this code is crude and untested, but it should give you an idea of what can be done. It would be prudent to keep this kind of code to a bare minimum, so that performance is not affected. In other words you should only be using this method when you have no other option.

Meta Tags

You could extend the render code sample to remove all of your non-compliant code if you want. I would suggest that this is not the best way of doing things. Another technique is to replace standard SharePoint controls with your own custom built controls. A simple example of where this can be done is with the RobotsMetaTag. Using Lutz Roeder's Reflector I was able to extract the following (simplified) code for the RobotsMetaTag control:

public class RobotsMetaTag : SPControl
{
 
protected override void Render(HtmlTextWriter output)
 
{
   
if (!SPControl.GetContextWeb(this.Context).ASPXPageIndexed)
   
{
     
output.Write("<META NAME=\"ROBOTS\" CONTENT=\"NOHTMLINDEX\"/>");
   
}
 
}
}

We can see that the META, NAME and CONTENT elements all violate the XHTML rule that stipulates all tags should be lower case. The offending line can be rewritten in a custom control as:
output.Write("<meta name=\"ROBOTS\" content=\"NOHTMLINDEX\"/>");

Now deploy the custom control to your SharePoint environment and add it to the master page in place of the RobotsMetaTag. Two more validation errors out of the way. I recommend using this approach wherever possible.

Content

Between the security trimming control, render code and custom control methods it is now possible to fix all validation errors and eventually get a conforming web page. Great, we have just made a virtually blank web page comply. The next step is to add all the content and navigation back in. To achieve total compliance it will be necessary to create a custom control for many of the components on each page. The trick here is to make these controls as re-usable as possible.
The majority of the content in your site will come from page layouts and thankfully most of the field controls output XHTML compliant code out-of-the-box. When you come across a control that doesn't comply, again, you will need to make your own.
When it comes to navigation you have a couple of options. Either create custom navigation controls from scratch, or extend the SharePoint AspMenu control, as the source code has now been released for this control.

Web parts

At first I thought web parts were going to be no trouble when it came to W3C validation. Most of the web parts I use have an XSL source editor so all that is involved is to make sure that the XML is transformed into valid HTML right? Wrong, unfortunately web parts such as the Data View Web Part use some surrounding tables for layout. This is intrinsically bad practice for web development and accessibility but worse is that the tables use all kinds of non-standard attributes. The only solution that I have found to this is to override the render method as explained earlier. I recommend keeping web part use to a minimum. Web part zones should definitely not be used; they introduce a large amount of layout tables and non compliant HTML.

Summary

Hopefully this gives you a bit of a starting point in getting a SharePoint WCM site XHTML compliant. It is definitely not a simple task, however if you are doing a lot of SharePoint development you are bound to come across a project that requires it (e.g. government sector work). I believe that Microsoft is quite aware of these compliance issues and they will hopefully be addressed in the next release if not a service pack. I plan to maintain this document over time as I discover better techniques for dealing with the various validation issues that SharePoint presents. Good luck in getting your site to validate, you can look forward to seeing the following message to reward your hard work.

xhtml valid message

Categories: WCM