Don't put HTML in your body field

I often see Drupal projects where people have put raw HTML code into their body or other rich-text fields.

Whilst it can be useful for short-term prototyping, I don't think it should be done for content that will be reused or kept for a period of time.

If you have structured HTML code in multiple nodes, you can't make changes without editing each instance.

What if you need to fix a bug and have hundreds or thousands of instances?

If you have inline styles, they won't be updated or affected by changes to your stylesheets, such as changing colour or font family.

Instead, create first-class components that use templates that are easier to change and maintain and have a single source of truth that adheres to your design system.

In Drupal, use structured data in fields with Paragraphs or Layout Builder and build the templates around them.

This makes it easier to maintain and also for people to add and edit content.

- Oliver

Was this interesting?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.