How to disable Kentico adding stylesheet link to end of <head>?

Deivi Robles asked on August 23, 2018 17:53

How can I remove this tag link css to type end of head. I'm using a custom css added to physical folder in the server. I need help because when valide the site in PageSpeed Insights the result of the query is Optimize CSS Delivery Thanks

Recent Answers


Deivi Robles answered on August 23, 2018 17:57

This is my site https://www.procapslaboratorios.com

0 votesVote for this answer Mark as a Correct answer

Arun Kumar answered on August 23, 2018 18:10 (last edited on August 23, 2018 18:14)

Have you checked your master template layout. It should be there either at the end of the layout/header. If you are not using the default theme then you can remove the CSS reference from Sites -> Stylesheet

0 votesVote for this answer Mark as a Correct answer

Deivi Robles answered on August 23, 2018 18:37

Hey @Arun Kumar I Checked it but this tags aren´t there. Also I did disable the CSS reference in Sites->Stylesheet. Can we try other solution?

0 votesVote for this answer Mark as a Correct answer

Arun Kumar answered on August 23, 2018 18:42

Check if there is any CSS Stylesheet web part added in master page or any other pages

0 votesVote for this answer Mark as a Correct answer

Deivi Robles answered on August 23, 2018 19:08

No,I haven´t any CSS web part in my template.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on August 23, 2018 20:41

Based on the source in the page you referenced you have a few things going on:

  • Your site is assigned a stylesheet in the Sites app.
  • You site code name (procaps) is the same as a directory under /App_Themes (/App_Themes/procaps) therefore IIS automatically delivers any CSS files automatically. THIS IS NOT A Kentico issue, it's how IIS functions.
  • You have references manually added to the master page which look they are duplicated

Start by removing all references and find out what is added automatically and what isn't.

If you want to manually add references to your site, remove the reference in the Sites application to your stylesheet. In the Sites application edit the specific site and set the site stylesheet to none.

Next go to the Pages app in the content tree and select the master page. After the page loads, select the Master Page tab. Verify your <head> tag references in there. I'm willing to bet you find some stylesheet references in there, remove them.

Now check the design tab of the page template. Look for any grey webparts which would be HEAD HTML webparts. They may have references to CSS in them. Set the visibility to not display.

Clear the cache on your site, log out and reload the page. What CSS files load? I'm willing to bet any files in the /App_Themes/procaps directory are showing in your <head> tag. The solution to fixing these "automatic" loading files, is to move them to a different directory. We typically put them in the site specific directory, yours may be /procaps. This way you have complete control as to when they load and what to load.

What I'd do now is:

  • Not assign a stylesheet in the Sites appliction
  • Move your files out of the /App_Themes/procaps directory
  • Add a HEAD HTML webpart to the master page and add all your stylesheet references in there. This will be the safest solution to being able to control what is loaded, where it's loaded and when it's loaded.
1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.