Skip to content
Grav 2.0 is officially stable. Read the announcement →
Themes & Styling

Css custom attributes not working

first-time theme

Solved by pamtbaau View solution

Started by Josh 6 years ago · 2 replies · 1177 views
6 years ago

Can someone help me understand why the code from the documentation is not working for me. I'm try to add custom attributes to my css load (so that I can bring in bootstrap) but custom attributes aren't working.

My code:
{% do assets.addCss('theme://css/styles.css',{'group':'mygroup'}) %} {{ assets.css('mygroup',{'rel':'alternate'}) }}

Is rendering as:
<link href="/user/themes/my-theme-name/css/styles.css" type="text/css" rel="stylesheet">

So... obviously not picking up my custom attribute. Here's the example from the documentation which is not working for me: https://learn.getgrav.org/16/themes/asset-manager#change-attribute-of-the-rendered-css-js-assets

Thanks.

6 years ago Solution

@skipper, Try switching on the 'pipeline' of css in '/user/config/system.yaml':

YAML
assets:
  css_pipeline: true

Note:

  • With css_pipeline: false, the options of assets.addCss(asset, [options]) are being used.
  • With css_pipeline: true, the options of assets.css(asset, [options]) are being used.

Same holds for assets.addJs() and assets.js()

last edited 08/13/20 by pamtbaau
6 years ago

Thank you. That got my attributes working.

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by stuart young, 2 weeks ago
3 251 2 weeks ago
Themes & Styling · by Sebadamus, 3 weeks ago
5 317 3 weeks ago
Themes & Styling · by martynfoster735, 4 weeks ago
1 310 4 weeks ago
Themes & Styling · by Justin Young, 1 month ago
1 348 1 month ago
Themes & Styling · by Slebeig, 2 months ago
4 474 2 months ago