Skip to content

Add class to body tag which represents the current page

Currently, to scope styles to a specific page we have the following options:

  1. page_css_file param
  2. header_wrapper_class and container params

The existing solutions have limitations.

Option 1 slows down build time and can lead to memory issues, as Laravel Mix builds all bundles in parallel.

Option 2 is cumbersome as we need to scope styles to a class that we need to add twice.

A nice quality-of-life improvement would be to have an automatic class generated based on the URL, which would always be present on the body element.

e.g.

  • https://www.eclipse.org/legal/privacy/ -> <body class="page-legal-privacy">
  • https://www.eclipse.org/research/projects/amass/ -> <body class="page-research-projects-amass">

This removes the need to set or overwrite front matter params.