Add css in partials

For example, I have a faq partials that needs to be used on nearly 30 pages. This will cause me to have to reference the css file corresponding to the faq on 30 pages. This will undoubtedly increase a lot of maintenance costs. I want to know what can be done. Is there a way to maintain partials and css together? Using field control in md is not a good idea for me, because similar pages reuse partials, and using field control will result in countless fields.

Why do you not just include the css for your FAQ in your global css?

This is not a global style. Even if dozens of pages need to use it, most pages do not need it. I don’t think adding styles to the global is a good solution, it will lead to more and more global styles

The general answer is yes.

You may conditionally include a style
You may use a combination of block and partial
You may define layouts based on your faq type
And many more

All that depends on your settings

  • config
  • theme
  • directory structure

Without more information about your setup you most likely won’t get a tip for your specific use case.

See: Requesting Help

2 Likes

To clarify, are you including the FAQ(s) in content by using a shortcode, or are you including the FAQ(s) in a template by using a partial?

If it is the latter, what criteria do you use to determine whether to call the partial?

Using a partial,normal reference in the page

What criteria do you use to determine whether to call the partial?

Is it always called from a particular single page template? If yes, is that single page template targeted to a particular page type or section?