Managing CSS Files in Sitecore

Sitecore is a content management system, but can it also be a web design management system?  The short answer is that you can design some solutions to provide flexibility for content management users to manipulate the the design via CSS files, allow them to manage and upload their own CSS files or make changes to the initial CSS files.

Read more for the configuration steps required to support CSS files as Sitecore Media Assets.

You will need to modify the App_Config/MimeTypes.config file in your project.

Edit the following:

<mediaType extension="css">

Replace with the following:

<mediaType extension="css">

Here is some sample backend C# code of how you would pull in the CSS file:

FileField cssFileField = Sitecore.Context.Item.Fields["CSS"];
Item cssItem = cssfileField.MediaItem;
string cssUrl =  Utilities.GetAbsoluteUrl(Sitecore.Context.Page.Page.Request, StringUtil.EnsurePrefix('/',Sitecore.Resources.Media.MediaManager.GetMediaUrl(cssItem)));
cssElement.Attributes.Add("href", cssUrl);

Note: Only CSS files that are uploaded to the Media Library after this config change are affected.

Here is a link to a Sitecore Forum post about the topic:


Add a comment
For Security please arrange
the letters to spell ‘OASIS’
  • O
  • A
  • S
  • I
  • S