Hi Ian,
This is a very common confusion when starting with Grav, so no worries 🙂
What’s happening is that inserting raw HTML into a .md file is not always the best approach for layout or styling changes like background colors. In Grav (and especially in themes like Future2021), it’s much cleaner to handle this via CSS and page-specific classes.
In your theme, there is already a mechanism prepared for this in base.html.twig:
<body class="{% block body_classes %}{{ page.header.body_classes }}{% endblock %} is-preload">
This means you can assign custom classes to the <body> tag from each page.
Recommended approach
- Add a class to your page
In your page’s .md file (or via the Admin panel → Advanced tab), add:
body_classes: custom-bg
- Define the CSS
Then, in your theme’s CSS file (e.g. custom.css), add something like:
body.custom-bg {
background-color: #f0f0f0;
}
Or if you want something more specific:
body.custom-bg .wrapper {
background-color: #f0f0f0;
}
Result
Only that specific page will have the new background color, without needing to inject HTML into your Markdown.
Extra tip
Grav Markdown files are mainly for content, not for layout or styling. For styling:
- Use CSS
- Use Twig templates
- Use page headers (like
body_classes)
This approach is much more flexible and avoids the issue you’re seeing where HTML is rendered as plain text.
Hope that helps!