There's any way to check if the current page is the homepage?
I want use h1
tag for the logo image only when the current page is the website base url.
You can use page.url
to check if the current page is your index page:
{% if page.url == "/index.html" %}
<h1>...</h1>
{% endif %}
Another option to manage this is adding page IDs to the yml frontmatter
{% if page.id == 'index' %}
content
{% endif %}
Along @Christopher's comment the best is if you test the page.layout
. Because if permalink is set or in other circumstances the page.url
can be "/index.html"
, "/index"
, or just simply "/"
. Therefore I think it's more robust:
{% if page.layout == 'home' %}
<h1>logo</h1>
{% else %}
<h2>smaller logo</h2>
{% endif %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With