Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add CSS to a TYPO9.5 Extension?

What is the correct way of adding CSS to the public folder of an extension? What do I need to do in order for that CSS to be loaded in.

For example I have the following structure:

Public/Css/style.css
Configuration/TypoScript/setup.typoscript
Configuration/TypoScript/constants.typoscript

Would I have to add some code in setup.typoscript?

like image 829
Kaasstengel Avatar asked Jan 29 '26 13:01

Kaasstengel


2 Answers

Since TYPO3 8.7 you can add HTML to the header or footer from your Fluid template using the HeaderAssets and FooterAssets sections. For example:

<f:section name="HeaderAssets">
    <link rel="stylesheet" href="{f:uri.resource(path: 'Css/styles.css')}"/>
</f:section>

The advantage of this over page.includeCSS is that it is only included whenever that template is rendered, instead of on all pages.

like image 178
Rudy Gnodde Avatar answered Jan 31 '26 03:01

Rudy Gnodde


Your CSS has to be in: extensionkey/Resources/Public/Css/

And then in your typoscript (setup) you can add:

page.includeCSS.csskey = EXT:extensionkey/Resources/Public/Css/style.css

The "csskey" has to be unique identifier.

like image 35
RinyVT Avatar answered Jan 31 '26 01:01

RinyVT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!