site

Table of contents

site

The site object is accessible everywhere. The site object has the following default attributes, but is also extendible by adding content fields.

site.name

Returns the site name.

site.id

Returns the site's id.

site.domain

Returns the site’s primary full domain. E.g. www.my-plate-site.com.

site.attachments

Returns all attachments in a collection, in this case the 'site' object.

site.trays

Returns all trays from a site.

site.post_types

Returns an array of liquid drops from all post_types in a site.

You can also loop through the array as follows:

{% for post_type in site.post_types %}
    {{post_type.title}}
{% endfor %}
site.post_types

site.section_types

Returns all section types of a site.

site.element_types

Returns all element types of a site.

site.abstract_content_types

Returns all abstract/generic content types of a site.

site.content_types

Returns all content types from a site.

site.languages

Returns an array of objects representing the available languages for the site.

Input:
{{ site.languages }}

Output:
[
  { "shortcode" => "nl", "name" => "Dutch, "url" => "/dutch-url" },
  { "shortcode" => "en", "name" => "English, "url" => "/en/english-url" },
  { "shortcode" => "de", "name" => "German, "url" => "/de/german-url" }
]
Input / Output site.languages

The url attribute returns the url of the translation for the Post you are on. If there is no translation found, the root url for the language is returned. E.g. ‘/en’ for English, ‘/fr’ for French, and so on.

Template
{% for language in site.languages %}
  <a href="{{ language.url }}">{{ language.name }}</a>
{% endfor %}

Output:

<a href="/dutch-url">Dutch</a>
<a href="/en/english-url">English</a>
<a href="/de">German</a> <!-- uses root german url if no translation is found !>

site.main_language

Returns the object representing the main languages for the site.

site.content_objects

Object that functions as a container for all generic content objects within your site, filtered by content type name.

content_objects is only callable as an attribute on the Site object.

content_objects.[:content_type_name]

Returns all Content Type kind: Generic Content for the given content type name in a collection.

E.g., when you have a content type with the (plural) name 'categories', site.content_objects.categories returns a collection object with all categories in it.

site.content_objects.[:plural_content_type_name]

Returns all Generic Content Objects for the given content type name in a collection.

E.g., when you have a content type with the (plural) name 'categories', site.content_objects.categories returns a collection object with all categories in it.

site.elements.[:plural_content_type_name]

Returns all Elements for the given content type name in a collection.

E.g., when you have a content type with the (plural) name ‘forms', site.elements.formsreturns a collection object with all 'Form’ elements in it.

You can also get all elements of a site in a collection: site.elements.all

site.[:plural_post_type_name]

Returns a collection with all posts (objects with the specified post type). E.g. 
{{ site.pages }} returns a collection with all posts with the content type ‘page’.


Need help?

Do you have any question which is not answered in this knowledge base? Contact us. We are here to help you.