subtheme - Load css to front page only

Created on 26 May 2021, over 3 years ago
Updated 3 March 2023, almost 2 years ago

Problem/Motivation

First time trying a bootstrap theme.
I'm in trouble to attach css file to front page only.
As I've done up to now in standard themes i added a library to bootstrap_barrio_subtheme.libraries.yml

# Custom front page
custom_front_page:
  css:
    theme:
      css/front.css: { weight: 1000 }

and added a suggestion to "_bootstrap_barrio_subtheme.theme"

function bootstrap_barrio_subtheme_preprocess_page(&$variables) {
  if ($variables['is_front']) {
     $variables['#attached']['library'][] = 'bootstrap_barrio_subtheme/custom_front_page';
  }
}

but the front.css file is not loaded

It has always worked well, what am i doing wrong now?
Many thanks to those who can help me understand how to do it

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Fixed

Version

5.5

Component

Documentation

Created by

🇮🇹Italy senzaesclusiva

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024