Posted 30th of June 2011 by Kern Herskind Nightingale

This is a question that I’m confronted with again and again - and just today it surfaced again: When should we use Sublayouts and when should we use XSL Renderings? Which is better?

I guess my answer has always been a bit vague; it depends on what you are trying to do! Use a screwdriver for screws and a hammer for nails.

I have always used XSLT renderings for simple presentation and I think it’s an elegant way of mixing markup with presentation logic. Obviously there is threshold where the presentation logic becomes too complex and is unmanageable in XSLT.

Rule of thumb: If you start contemplating XslHelper methods - you should probably consider doing a Sublayout instead.

Sublayouts is the way to go when there is any form of interaction (think POST packs and query string processing). One side effect of sublayouts is the temptation of using ASP.Net controls and the horrible markup they entail.

Performance wise I seem to recall that Sublayouts take approximately half the time to render than a XSL Rendering doing a comparable job. I must admit that this is not my biggest concern - as most performance issues can be mitigated with a good caching strategy.

An interesting contender is the Razor for Sitecore module that allows you to render Razor views. For pure presentation it looks to be much more slick than messing around with ListView’s etc.

Another thing to consider is also the skill level needed for the different techniques - it may be easier for a frontend developer to learn XSLT whereas an experienced ASP.Net developer would feel more comfortable doing web user controls.

I think there is none of the techniques that is a clear winner - they both have strenghts and weaknesses - so make the choice base on what you are trying to build.



blog comments powered by Disqus

About the author

Kern is a Sitecore Specialist with more than 10 years experince achitecting and developing Sitecore solutions. Kern was awarded Sitecore MVP in 2009, 2011 and again in 2015.
Currently Kern is helping the Sitecore Product team in shaping the future of the platform.

Kern Herskind Nightingale