9
votes

Can anyone tell me the difference between Renderings and Sublayouts in Sitecore and when each should be used? And does it make any difference when you are using MVC.

I've been going through a lot of tutorials / videos recently for Sitecore and sometimes presentation is created as a Sublayout, other times it's a Rendering both of which seem to work the same when you link it to an MVC view. There must be some difference but I haven't found anything that accurately explains what it is and when you should use each one.

2

2 Answers

16
votes

The difference between Renderings and Sublayouts are simply the file types that they each represent.

In WebForms, (which was the only option in Sitecore before 6.6) these are pretty much tied to the following:-

Renderings - XSLT
Sublayouts - Web Controls (.ascx files)

For MVC (Sitecore 6.6 and up), you have the Renderings for your different MVC types. The most commonly used ones are:-

Controller Rendering
View Rendering

If you're only using MVC components, then these are the ones you'd use, as Sublayouts are more for WebForms .ascx controls.

For help with these types, I'd recommend watching Martina Welander's SitecoreMVC tutorials:- https://www.youtube.com/watch?v=i3Mwcphtz4w
https://www.youtube.com/watch?v=dW_rQp9bMmE

1
votes

Basically, a Sublayout is a type of Rendering.
The reason why there are two different names is mostly because of legacy:

In "the old days" you used to only have:
- Sublayouts (= Renderings that use an ASP.NET User Control)
- Renderings (= Renderings that use an XSLT file)

The two having different names has pretty much become obsolete with the introduction of MVC and the slowly dying of XSLT.
If you are using MVC, you will not use Sublayouts at all, only Renderings of which you have multiple different types.

I try to only talk about "Renderings" and not mention the different types too much as it only confuses users.