Organizing Your CSS / SCSS Code

I almost completely switched to Sass in the past year. So organzing my CSS code has become a mission of mine :)

Structure is especially needed, when you are not the only one working on the design. So that everyone on the team can easily understand and contribute with ease. There are never too many files, as files get combined anyway.

Make your own life easier and for those you work with!

Currently applying the following structure on newer projects:

  1. sass/
  2. |
  3. |– base/
  4. |   |– _reset.scss       # Reset/normalize
  5. |   |– _typography.scss  # Typography rules
  6. |   ...                  # etc…
  7. |
  8. |– components/
  9. |   |– _buttons.scss     # Buttons
  10. |   |– _carousel.scss    # Carousel
  11. |   |– _images.scss      # Images
  12. |   |– _dropdown.scss    # Dropdown
  13. |   |– _navigation.scss  # Navigation
  14. |   ...                  # etc…
  15. |
  16. |– utils/
  17. |   |– _variables.scss   # Sass Variables
  18. |   |– _functions.scss   # Sass Functions
  19. |   |– _mixins.scss      # Sass Mixins
  20. |   |– _utils.scss       # Class & placeholders helpers
  21. |   ...                  # etc…
  22. |
  23. |– layout/
  24. |   |– _grid.scss        # Grid system
  25. |   |– _header.scss      # Header
  26. |   |– _footer.scss      # Footer
  27. |   |– _sidebar.scss     # Sidebar
  28. |   |– _forms.scss       # Forms
  29. |   ...                  # etc…
  30. |
  31. |– sections/
  32. |   |– _home.scss        # Home specific styles
  33. |   |– _about_us.scss    # About us specific styles
  34. |   ...                  # etc…
  35. |
  36. |– themes/
  37. |   |– _front_base.scss  # Parent theme
  38. |   |– _front_child.scss # Child theme
  39. |   |– _admin.scss       # Admin theme
  40. |   ...                  # etc…
  41. |
  42. |– vendors/
  43. |   |– _bootstrap.scss   # Bootstrap
  44. |   |– _bourbon.scss     # Bourbon Mixins
  45. |   ...                  # etc…
  46. |
  47. |
  48. `– app.scss             # primary Sass file
  49.  
  1. BASE holds files like resets, typography and foundation structures.
  2. COMPONENTS holds specific module definitions, like buttons, navigation etc.
  3. UTILS holds my own functions, mixins and configuration for the whole project.
  4. LAYOUT holds the main files defining the different layout areas / grid of the project.
  5. SECTIONS holds the definition of pages or sub sections defined.
  6. THEMES holds files for theme switches or front / backend layouts.
  7. VENDORS holds those files that are related to external includes.

Which architecture fits your project & team will vary.

Enjoy coding …

Alex

I am a full-stack developer. I love programming,  design and know my way around server architecture as well.  I would never feel complete, with one of these missing. I have a broad range of interests, that’s why I constantly dive into new technologies and expand my knowledge where ever required. Technologies are evolving fast and I enjoy using the latest. Apart from that, I am a peace loving guy who tries to have people around him that think the same.  I truly believe in the principle: “If you help someone, someone will help you, when you need it."

Recent Posts

B&B / Hotel Booking Solutions for WordPress | 2024

BOOKING SOLUTIONS 202x This is my take on a subset of booking, appointment, PMS or… Read More

4 weeks ago

WordPress Cron + WP-CLI + Ntfy

THE GOAL Create a system cron for WordPress, that is accessible and can be easily… Read More

2 months ago

2024 is here and now :)

2024, what's cooking? Slowly getting into the 2024 spirit. 3 projects coming to a close… Read More

4 months ago

2023 ends and whats next !

Short look back at 2023 This has been a busy and interesting year. I am… Read More

4 months ago

cubicFUSION Grid Tweaker – Elementor Grid made easy.

Elementor Pro provides grid containers as an experimental feature. The options provided are limited, when… Read More

5 months ago

Archaeology Travel Booth – Travel Innovation Summit 2023

Archaeology Travel is an online travel guide for people who enjoy exploring the world’s pasts.… Read More

6 months ago