7

I would like to deploy my CSS and JS files outside of Tridion using a CI process or file copy, and not store the CSS or JS files in Tridion itself.

In the _Layout.cshtml file I see the CSS and JS files referenced. Is this all I need to change to reference the CSS located outside of Tridion? And, any tips or suggestions for doing it this way?

C:\dev\dxa-example-site-dotnet-master\dxa-example-site-dotnet-master\Site\Views\Shared_Layout.cshtml

<link rel="stylesheet" href="@Url.VersionedContent("/assets/css/main.css")">
<script src="@Url.VersionedContent("/assets/scripts/header.js")"></script>
5

Just remove @Url.VersionedContent and put regular href

<link rel="stylesheet" href="/assets/styles/main.css">
  • You don't even need to remove the @Url.VersionedContent as long as you make sure there is no HTML design published and you deploy a version.json file to the /system/assets folder of your Web application, which contains the version number which is added to the URLs for static assets. – Bart Koopman May 30 '17 at 13:31
1

The _Layout.cshtml file is indeed the equivalent of a master page, which takes care of defining the basic HTML page being served, which includes the links to your stylesheet. But you shouldn't even need to make any changes in there, as long as you make sure your own CSS is called main.css (if you want to use a fifferent file name, or even multiple, then you can of course also do that and modifly the _Layout.cshtml accordingly).

As I described in my blog post about DXA HTML design decisions, you can simply follow the following four steps to use an "external" HTML design:

  1. delete the Publish HTML Design Page (you can also delete the Component on it and its references, but simply unpublishing and deleting this page, makes the HTML design unavailable from the Broker database).
  2. deploy a version.json file to the /system/assets folder of your Web application, which contains the version number which is added to the URLs for static assets, i.e.: {"version":"v0.1"}
  3. deploy your CSS, fonts and JavaScript files to the to the /system/assets folder (as part of the deploy of the web application with its views)
  4. update the views in case you need the HTML to be non Bootstrap

Step #1 is optional (you can leave it behind as long as you make sure it is not published), but step #2 is mandatory!

This will give you an HTML design which you deploy as part of the web application, while still being able to utilize the browser/client side caching control of the static assets through the version.json file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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