Prevent CSS file from getting localized
-
11-12-2020 - |
Question
In my master page, I have reference to theme file as-
<SharePoint:CssRegistration Name="Themable/corev15.css" runat="server" />
My problem is on my site for different locales, the CSS file is getting localized
Like, for en-us site theme CSS reference is from (on initial load) -
<site collection url>/_catalogs/theme/Themed/28DE9520/corev15-65D9856.themedcss
But for some other locale pt-br, the reference for theme file is like -
<site collection url>/_layouts/15/1046/styles/Themable/corev15.css
Can I have a solution for this where CSS file is always referenced from -
<site collection url>/_catalogs/theme/Themed/28DE9520/corev15-65D9856.themedcss
Solution 3
Using attribute EnableCssTheming="true"
in SharePoint:CssRegistration
tag restricts the file to take it from <site collection url>/_catalogs/theme/Themed/28DE9520/corev15-65D9856.themedcss
path irrespective of user locale
Hence, the solution which worked for me is -
<SharePoint:CssRegistration Name="Themable/corev15.css" EnableCssTheming="true" runat="server" />
OTHER TIPS
Try taking the CSS out of the hive and placing it in the Style Library => en-us => Themable folder at the top level of your site collection. This is considered best practices for SharePoint 2013 anyways. Also, make sure your css runs after the cores.
<SharePoint:CssRegistration ID="CssRegistration" Name="/Style Library/en-us/Themable/customized.css" runat="server" After="corev15.css" />
The CSS reference is generic for whatever theme you have active in the site.
<SharePoint:CssRegistration Name="Themable/corev15.css" runat="server" />
The folder id is generated when you apply a theme to a specific site:
e.g. /_catalogs/theme/Themed/28DE9520/corev15-65D9856.themedcss
different sites will have different theme folders so you should definitely not use hardcoded paths to the theme file.
Therefore, I suggest you look into an altenative approach:
- Make sure you apply the same theme (aka "Composed Looks") throughout the sites
- See How to: Make custom CSS files themable in SharePoint 2013
- Use a custom CSS file stored in either the hive or Style Library