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.
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 %}
{% if page.url == "/" %}active{% endif %}
–
Axes page.url == "/"
works fine (v3.4.3). –
Andrey 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 %}
© 2022 - 2024 — McMap. All rights reserved.
{% if page.layout == 'home' %}
but your answer is correct too. Thanks! – Weimaraner