Tags.
Standard Liquid tags all work. On top of them FleekSite registers seven custom tags, for reading data, composing templates, injecting head content and making HTTP requests. Each registers under both snake_case and PascalCase.
The standard tags (assign, if, for, capture, case and the rest) behave as they do in any Liquid engine. The composition tags {% include %}, {% render %} and {% layout %} are covered under Partials and includes, because what they do depends on the render mode. This page documents the seven FleekSite tags.
collection
Queries the site database: posts, products, users, orders, bits, redirects, templates and more. It is the main way a template reads data.
{% collection products, items, limit: 6, order: inserted_at desc %}
{% for product in items %}
href="{{ product.permalink }}">{{ product.title }} {{ product.price | price }}>
{% endfor %}The first argument is the source, the second is the variable the results land in. The tag also sets a variable and a paginate object. Because it has a full vocabulary of filters, sorts and paging, it has its own page: see The collection tag and Data sources.
partial
Includes another template by its title, rendered in the current context. It is the composition tag that works in both render modes.
{% partial header %}
>{{ page.body }} >
{% partial footer %}The argument is the template title. A missing template renders a single space rather than an error, so a stray include never blanks the page. The included body sees the full page context (site, page, bits and so on) and inherits the render mode. In standard mode the native {% include %} resolves the same way; {% partial %} is the portable choice.
meta_resource
Renders a template and stores the result for injection into the page head, producing no inline output. Use it for custom meta tags, structured data or head scripts that a template needs to add.
{% meta_resource custom-seo %}The argument is the title of a template on your site. That template is rendered with the current context and its output is added to the head during the meta pipeline. See SEO and meta.
fetch
Makes an inline HTTP request and binds the full response to a variable.
{% fetch "https://api.example.com/rates" as rates %}
{% if rates.success %}
{{ rates.data.usd }}
{% else %}
{{ rates.error }}
{% endif %}The bound variable carries data (parsed as JSON when the response is JSON, otherwise text), status, success, headers and error. Pass options as a JSON object before as to set the method, headers, body or timeout:
{% fetch "https://api.example.com/orders" {"method":"POST","body":{"ref":"A12"}} as result %}The default timeout is five seconds. The URL can be a literal or a context variable.
prefetch
Runs an HTTP request defined by one of your templates. The named template is rendered to JSON, that JSON is read as a request specification, and the response is bound to a variable named after the template.
{% comment %} A template titled "weather-api" that renders a JSON request spec {% endcomment %}
{% prefetch weather-api %}
{% if weather-api.state == 'ok' %}
{{ weather-api.body.temperature }}
{% endif %}The request template must render valid JSON of the shape {"url": "...", "method": "GET", "headers": {}, "body": {}}. For a GET the body becomes the query string. The result is {state: 'ok', body} on success, or {state: 'error', reason} on a bad template, bad JSON or a failed request. The timeout is five seconds. Use prefetch when the request should be configured in a template; use fetch for a one-off inline call.
bit
Emits the value of a named site bit. The argument is the bit name, bare or quoted; it is treated as a literal name, not a context lookup. The first bit with that name across all categories wins.
{% bit 404_message %}
{% bit "tagline" %}{% bit %} renders the value in Standard mode only. In Compat it renders nothing. To read a bit in any mode, use the bits object, for example {{ bits.general.tagline }}. See Bits.
minusone
Emits a numeric value minus one. It exists for a legacy paging idiom; in new templates plain arithmetic ({{ n | minus: 1 }}) is clearer.
{% assign n = 10 %}{% minusone n %}
{% comment %} => 9 {% endcomment %}A non-numeric value emits nothing.