I’d like to add same content but assign a different tag in haml for the sake of SEO.
More specifically, I want the header to be <h1>
in PostsController#index
but to be <p>
on other pages so I try to use
-if current_page?(controller: 'top', action: 'index') ? %h2 , %h3
but it doesn’t work and I think the wrong part in %h2
%h3
part.
2
Answers
I’m not that familiar with HAML but perhaps this?
You can use the
haml_tag
helper, something like this:Note that the helper arguments are symbols, using
:
not%
.