Skip to documentation content

Shared and Pageless Content

Shared and Pageless Content

Datastores whose items never have their own page, a block that appears in more than one place, and loading a settings record once.

Pages without page items
CreatePageByDefault only sets whether the editor's "give this item its own page" option starts checked (see CreatePageByDefault). It does not decide whether the datastore itself can be a page. A Testimonials datastore with CreatePageByDefault false can still carry a URL and listing TemplateGUID, so /testimonials is a page while no testimonial gets a URL of its own. The same items can be picked onto Home or any other page with a datastore item list field, so the text lives in one place. FAQs and calls to action work the same way: pages pick them, and a menu route can land on the datastore.
A block that appears in more than one place (testimonials on Home and on /testimonials, one call to action on many pages) should name its source: the datastore and the picker field that selects from it, for example Home's featured_testimonials field, a datastore item list over Testimonials. Keeping a second copy of the text in a settings record or in a section's own fields is also valid; the cost is that the copies drift apart.

Loading the settings record once
Load the settings datastore by name, near the top of the shared header, and give every partial the one variable:

{% datastore_items var site_settings = datastore:'Site Settings' limit:1 %}
{% assign settings = site_settings.fetched[0].data %}

Partials then read settings.company_phone and the like. Loading by name rather than GUID keeps the code working on every site the template is copied to.