Adding classes to posts

I’ve been looking for a way to add classes on some posts for layout purposes.

I’ve come up with the following:

Added a new parameter in a post’s front matter:
classes = "featured"

And then in the template I call it like this:
<div class="post {{ with .Params.classes }}{{ . }}{{ end }}">

Is this the correct way to go about it?

That looks fine to me (except I’d put the space on the other side of the with).

1 Like