Best practice for modifying and implementing gin theme

Created on 16 February 2022, over 3 years ago
Updated 10 April 2023, over 2 years ago

Problem/Motivation

Needing to alter css, js, templates in gin theme

Steps to reproduce

I have looked at custom css issues for the gin theme and there seems to be some conflicting information. I have the following related questionsregarding the bestpractices for implementing the gin theme:

  • Should I implement a subtheme? (I see some posts that say NO due to the way gin was implemented)
    • If NO is it ok to modify the gin core theme?
    • if YES gin theme css seems to take precident. How do you add a custom.css. I saw mention of security issues with gin-custom.css in the root folder. Is it best practice to use this in the sub_theme.theme file?
      /**
       * Set Vodka CSS on top of all other CSS files.
       */
      function vodka_css_alter(&$css, $assets) {
        // UPDATE THIS PATH TO YOUR MODULE'S CSS PATH.
        $path = drupal_get_path('theme', 'vodka') . '/dist/css/YOURCUSTOMFILE.css';
      
        if (isset($css[$path])) {
          // Use anything greater than 200 to have it load after the Gin theme
          $css[$path]['group'] = 201;
        }
      }
      

Proposed resolution

Document Best practice for modifying and implementing gin theme and put it on the theme homepage for clarity.

πŸ’¬ Support request
Status

Closed: works as designed

Version

3.0

Component

Documentation

Created by

πŸ‡ΊπŸ‡ΈUnited States CProfessionals

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.

  • πŸ‡¦πŸ‡ΊAustralia sime Melbourne

    I decided to stop sub-theming Gin after I ran into design elements that would have forced me to reimplement a lot of my own logic. I am going with the custom css file option as it's usually just a little CSS I wish to override.

  • πŸ‡©πŸ‡ͺGermany kle

    I often add some custom templates for better editing-experience - this wont work without creating a subtheme. So gin for me is not possible.

Production build 0.71.5 2024