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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

Css custom attributes not working

first-time theme

Solved by pamtbaau View solution

Started by Josh 6 years ago · 2 replies · 1016 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 Pedro M, 2 months ago
4 193 2 months ago
Themes & Styling · by Ian, 2 months ago
3 91 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 451 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 45 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 125 3 months ago