20

I'm using SharePoint 2013 and I have created master page file (as .html) and converted it to .master file. As I have read, I should only modify html file, because all changes will be also registered in .master file and this doesn't work in opposite way.

I have also read, that I should keep css files and images in style library. The problem is, that all tutorials say that, but just for example, they are keeping those files in Master Pages folder. So I'm using:

<!--SPM:<SharePoint:CssRegistration Name="<% $SPUrl=~sitecollection/Style Library/MyCustomTheme/mycss.css%>" runat="server" After="corev15.css"/>-->

And this causes a problem on site: "An error occurred during translation of your HTML master page. For more information, please navigate to the master page by clicking the preview button in the Master Page Gallery or directly typing its URL".

If I'm not using SPUrl, but instead just a direct link to file, everything works fine, so there is no problem with CssRegistration - I don't know what's the issue here?

I also need to pack my custom design to .wsp file. When keeping all stuff in Master Pages folder, it can by done by Design Manager (automatically packs what's needed). If I keep some files in Style Library, will the Design Manager also pack them to solution?

morleyc
  • 261
  • 1
  • 6
  • 14
Marcin Bigoraj
  • 343
  • 1
  • 3
  • 6

3 Answers3

16

This issue caused by angle brackets "<" to fix it replace it with "&lt" as below:

<!--SPM:<SharePoint:CssRegistration name="&lt;% $SPUrl:~sitecollection/_catalogs/masterpage/css/style.css %&gt;" runat="server"  />-->
Shannak
  • 506
  • 7
  • 9
3

i dont think your doing it properly!

<SharePoint:CssRegistration Name="<%$SPrl:~sitecollection/Style Library/MyCustomTheme/mycss.css%>" runat="server" After="corev15.css"/>

you were doing "<% $SPUrl=~ instead of "<%$SPrl:~

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.cssregistration.aspx

EDIT

try

<SharePoint:CssRegistration Name="<% $SPUrl:~SiteCollection/Style Library/Core Styles/mycss.css%>" runat="server"/>

after digging around i found that most examples are storing their css in the core styles folder, i dont know why but they are, maybe you can add your custom folder to that folder. also you dont need After="corev15.css", well spotted loool I didnt notice the typo loooool, also make sure when you add the css to the hive folder that it has the correct permissions on the file and that you do an iisreset

so it would look like this if you add the folder:

<SharePoint:CssRegistration Name="<% $SPUrl:~SiteCollection/Style Library/Core Styles/MyCustomTheme/mycss.css%>" runat="server"/>
Ali Jafer
  • 17,808
  • 1
  • 27
  • 41
  • Sorry, I have made a typo there. I'm not using the sign of equality. But with spaces I have tried all combinations, because I have seen over the web all variations, as in: here or here. Obviously, there is a typo on msdn too, because it should be "SPUrl" not "SPrl". And as I said: I tried all combinations, even with "SPrl". – Marcin Bigoraj Mar 04 '13 at 09:33
  • ammended my answer – Ali Jafer Mar 04 '13 at 09:46
  • Unfortunately, nothing of above works. I have also tried adding "~language" to expression and putting my file in "en-us" folder, but the error is the same. I have played with permissions, but also nothing helps. – Marcin Bigoraj Mar 04 '13 at 15:57
  • You will need the "After" attribute if you are overriding styles in the core CSS. This allows you to have your CSS rendered after the css file mentioned. You don't need to include the After attribute if your style rules are more specific, however. – Neil Monroe Oct 24 '16 at 17:16
1

This works fine for me, in the html master file :

<!--SPM:<SharePoint:CssRegistration ID="CustomCSS" name="&#60;% $SPUrl:~SiteCollection/_catalogs/masterpage/css/custom.css%&#62;" After="corev15.css" runat="server"/>-->
Ben
  • 11
  • 1