New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert body class #5

huphtur opened this Issue Jan 16, 2015 · 2 comments


None yet
3 participants

huphtur commented Jan 16, 2015

Mind if I contribute the following snippet?

<body class="{% if page.title %}post{% else %}home{% endif %}">

A quick hack to add a class to the body to differentiate between a homepage and post for layout purposes.


This comment has been minimized.

XhmikosR commented Jan 24, 2015

This is very specific to your use case and cannot be applied widely.

You could do something like this:

<body{% if page.slug %} class="{{ page.slug }}"{% endif %}>

paired with a replace to handle all cases like spaces etc.


This comment has been minimized.

wgallop99 commented May 13, 2016

This article was a huge help. A simple ruby plugin that adds a body class to your default template, depending on the title or layout of the page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment