RSS Feed with Razor in Umbraco

Razor Macro to generate RSS feed for a document type.

Posted on Saturday, August 23, 2014

The aim of this snippet is to render a XML RSS feed within Umbraco running in MVC mode. 

The idea I have used is have a RSS feed for document type of Press Release.

Step One

Create a document type of 'PressRelease' with properties:

  • Title (string) - alias = title
  • Published Date (DateTime) - alias = publishedDate
  • Summary (multi Text Box) - alias = summary
  • Body Text (rte) - alias = bodyText

(create and publish some content!)

Step Two

Create a partial view macro called 'Razor', create Macro at same time.


Notes: Line 24 :


'<link> is a recognised by razor, therefore we need to use Html.Raw to enable this link of code to work.

Step Three 

Create a Template called RSS. Within this template:

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
Layout = null;

Then you can simple, by using the alternate template , call the feed  by  eg.
This will render the XML RSS feed to be consumed by rss readers.


Parameters. Use macro parameters to enhance the RSS to choose document type, numbers returned etc.