I have a Blog where everything is on one template. The entries don't have an own url.

{% for entry in craft.entries.section('blog') %}
    {# everything #}
{% endfor %}

Now I want to give this page a title.

I could create a single called Blog page to have a title and a url. But isn't that a bit much for just a title? I hate to have a single with almost no content in the control panel. Could there be a better way to add a title to that page?

Globals? Categories? Something else?

How do you handle that?

  • 1
    If the template this is on is purely the blog page, could you not just do a simple static <h1>Page title</h1> above the loop? – Alec Ritson Feb 18 '15 at 9:59
  • Yeah. But it would be nice if it's triggered trough the cms because it will be a multilanguage page. – KSPR Feb 18 '15 at 10:12
  • Oh okay sure, have you seen this article? buildwithcraft.com/help/static-translations it shows you how to achieve translations with static content :) – Alec Ritson Feb 18 '15 at 10:14

If there's only this one page, I'd probably also use a Global Set instead of a Single Section for this.

Add a Global Set with the handle siteInfo and add a Plain Text field title for your title to it, make sure to mark it as translatable. Then in your template access it via {{ siteInfo.title }}.

The good thing with this approach is that you can allow your client to edit the title (for all locales), without having her edit the template or the static translations file. And! You can later add other fields to it, e.g. for other site metadata (description, open graph, etc.) or to change the site's theme.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.