# If query for {{ page.title }} vs. {{ site.title }} in blueprint

**URL:** <https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434>\
**Category:** Questions\
**Created:** [September 5, 2023, 7:06pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434 "2023-09-05T19:06:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![GB\_DESIGN](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gb_design/32/14956_2.png) [@GB\_DESIGN](https://forum.getkirby.com/u/GB_DESIGN)\
**Post date:** [September 5, 2023, 7:06pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434/1 "2023-09-05T19:06:24Z")

</div>

In all my blueprints there is a tab with SEO settings.  
`site/blueprints/tabs/seo.yml`  
The kirbyzone sitemapper plugin is also used.  
In the panel I can then select if the particular page should be added to the sitemap.  
In the help text is a link that shows **sitemap.xml** :

```auto
  sitemap:
    extends: fields/sitemap
    label: sitemap
    help: 'Show "{{ page.title }}" in (link: {{ site.url() }}/sitemap.xml text: sitemap target: _blank)?'

```

**page.title** , however, understandably does not display a page title on site.yml, **site.title** should be there. I assume that such a query is not possible in the blueprint?

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 5, 2023, 7:28pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434/2 "2023-09-05T19:28:21Z")

</div>

> [@GB\_DESIGN](#):
>
> does not display a page title on site.yml

But why should it? Maybe I’m missing something, but why would this field be used in site.yml when it is about including pages in the sitemap?

---

<div class="post-metadata">

**Author:** ![GB\_DESIGN](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gb_design/32/14956_2.png) [@GB\_DESIGN](https://forum.getkirby.com/u/GB_DESIGN)\
**Post date:** [September 5, 2023, 7:47pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434/3 "2023-09-05T19:47:46Z")

</div>

It’s more of a cosmetic issue, as no page title is shown in the help text:  
**show “” in sitemap?**

There should be the page title from “site.yml”:  
**show “Home” in sitemap?**

I have now created a separate blueprint for “site.yml” for the SEO settings.  
I wanted to avoid that, if an if/else query would be possible in the blueprint like this:  
`if blueprint is ‚site.yml‘ write {{ site.title }} else {{ page.title }}`

---

<div class="post-metadata">

**Author:** ![Khepri.Design](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/khepri.design/32/13857_2.png) [@Khepri.Design](https://forum.getkirby.com/u/Khepri.Design)\
**Post date:** [September 5, 2023, 7:57pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434/4 "2023-09-05T19:57:13Z")

</div>

I did not dive super deep into that but maybe just check if **page.title** is null and then print **site.title**

---

<div class="post-metadata">

**Author:** ![Khepri.Design](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/khepri.design/32/13857_2.png) [@Khepri.Design](https://forum.getkirby.com/u/Khepri.Design)\
**Post date:** [September 5, 2023, 7:57pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434/5 "2023-09-05T19:57:45Z")

</div>

maybe not null but an empty String

---

<div class="post-metadata">

**Author:** ![GB\_DESIGN](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gb_design/32/14956_2.png) [@GB\_DESIGN](https://forum.getkirby.com/u/GB_DESIGN)\
**Post date:** [September 5, 2023, 8:02pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434/6 "2023-09-05T20:02:41Z")

</div>

That is my question, whether such a query is possible in the blueprint.  
Maybe it’s possible with this?

> **[Query language](https://getkirby.com/docs/guide/blueprints/query-language#advanced-query-syntax)**
>
> Kirby comes with a blueprint query language that offers basically the same functionality as Kirby's PHP API with a simple dot notation.

Unfortunately I am not familiar with this, how the query for the current blueprint name works.

---

<div class="post-metadata">

**Author:** ![Khepri.Design](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/khepri.design/32/13857_2.png) [@Khepri.Design](https://forum.getkirby.com/u/Khepri.Design)\
**Post date:** [September 5, 2023, 8:08pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434/7 "2023-09-05T20:08:17Z")

</div>

This should work i guess: `"{{ page.title.isEmpty ? site.title : page.title }}"`

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [September 5, 2023, 8:29pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434/8 "2023-09-05T20:29:13Z")

</div>

that won’t work because there is no page object, hence no field object and therefore you cannot check for empty.

I’d just extend the field, when used in site.yml context, use site.title in help text, otherwise page.title.

---

<div class="post-metadata">

**Author:** ![Khepri.Design](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/khepri.design/32/13857_2.png) [@Khepri.Design](https://forum.getkirby.com/u/Khepri.Design)\
**Post date:** [September 5, 2023, 8:47pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434/9 "2023-09-05T20:47:20Z")

</div>

Interesting, so page would return undefined here instead of null? That would be the reason why checking with ‘??’ is not working aswel

---

<div class="post-metadata">

**Author:** ![GB\_DESIGN](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gb_design/32/14956_2.png) [@GB\_DESIGN](https://forum.getkirby.com/u/GB_DESIGN)\
**Post date:** [September 5, 2023, 9:08pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434/10 "2023-09-05T21:08:25Z")

</div>

In my case, it is not necessary to query whether the page title is empty, but whether the current blueprint is **site.yml** or not. The following solution works with all other templates (default.yml, contact.yml etc.), but not on the **site.yml** template.

`{{ site.blueprint('site') ? page.title : site.title }}`

---

<div class="post-metadata">

**Author:** ![GB\_DESIGN](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/gb_design/32/14956_2.png) [@GB\_DESIGN](https://forum.getkirby.com/u/GB_DESIGN)\
**Post date:** [September 5, 2023, 9:17pm UTC](https://forum.getkirby.com/t/if-query-for-page-title-vs-site-title-in-blueprint/29434/11 "2023-09-05T21:17:55Z")

</div>

Unfortunately this does not work, because `templates/tab/seo.yml` contains another reference which is assigned to the sitemapper plugin:

`templates/tab/seo.yml` :

```auto
  sitemap:
    extends: fields/sitemap <---
    label: sitemap
    help: "{{ site.blueprint('site') ? page.title : site.title }} ...

```

In this nested layer I can’t access the `help`-field with `extends` anymore.  
I duplicated `templates/tab/seo.yml`, renamed it and relabeled the `help`-field in it.  
I thought I could solve this with an if-query. But with a duplicated blueprint it also works for me.
