Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've been looking on the net for some advise and explanation about where to put my custom css and images for the master page in sharepoint 2010. I'm now busy with branding the portal and i'm a bit confused where the css files and images should go.

I have few options, either i put the files into the portal itself in the style library (document library) or I put them in the hive (ofcourse with the solution) And if in the hive in what directory exactly? 1033/Styles? (if in this one i would really like to know why?, why is 1033?) /Images? Other place?

Ofcourse i can put my files where ever i want but i would rather hear the best practise (the best place, the normal way of doing it).

share|improve this question

3 Answers 3

up vote 6 down vote accepted

If you want a super user to be able to change logos etc, or if the logo is specific to a site collection, place them in a subfolder in /Style Library/Images/.

However often you dont want the layout files of your page, or your CSS for that matter, to be changed by end users. This is a good reason to place them somewhere in the v\TEMPLATE\LAYOUTSfolder. These files are also available across all site collections in the farm as/_LAYOUTS`.

Exactly where under LAYOUTS really depends... If they should be able to change depending on language, you should place them under each language in LAYOUTS\<LCID>\IMAGES\yourSubDir or LAYOUTS\<LCID>\STYLES\yourSubDir (you will have one folder for each language pack you have installed).

When inserting CSS use the <Sharepoint:CSSRegistration ../> web control in the master page, SharePoint will pick the relevant localized CSS file depending on the language selected by site owner or user (see my blog post for more info) and possible caveats. This will also make sure that your CSS file is not cached when it is changed.

SharePoint libraries in general have "issues" with max-age header, which would cause excessive requests to the server even though page is cached

As you state, you can put them anywhere you want, and as you can see the answer (as usual with SharePoint is "it depends"). It is not the first time we discuss this either. Check similar question here.

On a final note, they way the files end up where they do is important too! You should always use Solutions and if needed Features to provision the files no matter where you decide to stick them!

EDIT: Files that should be published in a SharePoint library must be published using a Module element in a feature. Here you want to set it to be GhostableInLibrary. Example:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="MyWelcomePageTemplate" Url="$Resources:osrvcore,List_Pages_UrlName;" Path="MyWelcomePageTemplate">
    <File Url="default.aspx" Type="GhostableInLibrary">
      <Property Name="Title" Value="My page" />
      <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyPageLayout.aspx, $Resources:cmscore,PageLayout_WelcomeLinks_Title;" />
      <Property Name="ContentType" Value="MyContentType" />
    </File>
  </Module>
</Elements>

On the other hand you include LAYOUT files using Mapped Folders (directly to SharePointRoot or LAYOUT depends on your preference) that automatically is added as <RootFile ..> elements in your package/solution

share|improve this answer
    
Good explanation. But if I use feature to put the css and image files, they will be automatically placed in /Template/Feature/featurename/specified pad (is this good?) And if in my solutin i put module style libarary / images (according to this link msdn.microsoft.com/en-us/library/gg447066.aspx) when then in sharepoint i go to the style library, i see the structure but no files in it :( –  Shkipper Jun 28 '12 at 7:47
    
The folder you mention is only where the module files of the feature is placed. If you want to place the files in a SharePoint library, you should specify them as Type="GhostableInLibrary". That way the database entry in the library will point to the physical file location on the disk. More on GhostableInLibrary here or Google it :-) If you want to place files in Layouts folder, just add a Mapped Folder to LAYOUTS in Visual Studio. These files is not placed in a feature/module but is included directly in soultion as RootFile's –  Anders Rask Jun 28 '12 at 8:46
    
Updated answer to include guidance on modules and rootfiles –  Anders Rask Jun 28 '12 at 8:54
    
So when it is ghostableinlibrary the files will not be placed into the feature folder? They will only be placed into library (db) not the virtual directory –  Shkipper Jun 28 '12 at 9:46
    
no, when it is GhostableInLibrary the item is not placed in the database. Instead a reference to the file in the feature folder is used. An example of an Unghosted (in "modern" SharePoint terms referred to as Customized) would be if you for example edited a Page Layout in SharePoint designer. That would customize the page and the link to the file system would be replaced by a BLOB in the database –  Anders Rask Jun 28 '12 at 10:28

Why 1033? It is Decimal Language Code for English - United States. So if you have style/images/resources that target a different language you should use the appropriate language code.

Personally I would not use the ..Styles/ ..Images/etc folders directly but I would use a subfolder in them (i.e. 1033/Styles/MyProject or 1033/Images/MyCompany). This way you can easily find your custom files in the 12 hive.

share|improve this answer

I believe you should put all the branding design stuff in the Style Library. The 1033/Styles folder is for custom development css file.

Find out more here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.