views:

127

answers:

1

I have installed sharepoint 2010 on a single machine in farm mode pointing to a db on another server. I would like to start dabbling into branding the site by doing something that I initially thought to be trivially straightforward, link to a custom CSS from a SharePoint 2010 master page.

I have uploaded a custom css (Let's call it custom.css) using sharepoint designer in the Site Assets. What syntax do I need to put to link to it? I have tried the following:

<SharePoint:CssRegistration name="custom.css" After="corev4.css" runat="server"/> 

But the server cannot find the CSS file. I receive the following error:

Cannot make a cache safe URL for "1033/styles/custom.css", file not found. Please verify that the file exists under the layouts directory.

  • I've assumed I need to use SharePoint:CssRegistration - Is my assumption correct?
  • So what is it exactly that I need to put in the name tag to link to a css uploaded via sharepoint designer?
  • Am I even on the right track or would you suggest an alternative way of putting this together?

Thanks!

A: 

I would use Alternate CSS first. But other options are:

  • If you put the CSS file in Style Library, you can do this:

    < SharePoint:CssRegistration name="<% $SPUrl:~SiteCollection/Style Library/custom.css%>" runat="server"/>

  • Put the CSS on the server as 14\TEMPLATE\LAYOUTS\1033\STYLES\custom\custom.css and then you can do this:

    < SharePoint:CssRegistration name="custom/custom.css" runat="server"/>

Putting the file into its own directory is considered best practice so that it does not interfere with updates to out of the box files.

Rich Bennema