How to check if the home page is static site-wide
Posted: Sat Aug 27, 2022 3:12 am
Hey y'all,
So I want to show a link in my theme's header on every page if (and only if) the home page is static. In Chyrp Lite, I accomplished this with a frankly super ugly Twig hack:
Now, I figure this could be replicated with a similar trick with PHP in Bludit, but I'd like to know if there's a better and more elegant way, e.g.:
I'd like to avoid looping through pages more than necessary if I don't have to.
So I want to show a link in my theme's header on every page if (and only if) the home page is static. In Chyrp Lite, I accomplished this with a frankly super ugly Twig hack:
Code: Select all
<div class="logo">
{# The logotype goes here. #}
<h1><a href="{{ url('/') }}">{{ site.name }}</a></h1>
{# If the blog has a static home page, a link to the blog will be shown in the header. If you want to use a different slug for your home page, change it below. #}
{% if theme.pages_list() is not empty %}
{% for item in theme.pages_list %}
{% if item.slug == "home" %}
<span>/ <a href="{{ url('/index') }}">blog</a></span>
{% endif %}
{% endfor %}
{% endif %}
</div>
Code: Select all
if homepage is static
print my link
endif