How to check if the home page is static site-wide

Post Reply
ezequielbruni
Jr. Bludit
Posts: 7
Joined: Fri Nov 02, 2018 8:04 pm

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:

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>
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.:

Code: Select all

if homepage is static
	print my link
endif
I'd like to avoid looping through pages more than necessary if I don't have to.
Post Reply