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

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:

  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?

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?

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 }}

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

maybe not null but an empty String

1 Like

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

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

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

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.

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

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 }}

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

templates/tab/seo.yml :

  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.