Skip to main content

r:site:{attr}

<r:site:{attr} />

This is not truly a tag, but rather a format you would use to get properties about the site, where {attr} is replaced by the information you are retrieving.

This is the list of valid tags that follow this format, along with their descriptions:

  • <r:site:name />- The name of the current site.
  • <r:site:id />- The ID of the current site as seen in your browsers URL bar (e.g., https://cleanslate.wvu.edu/sites/1). In this case, "1" is the site ID.
  • <r:site:domain />- The primary domain of the current site as listed in Manage > Settings.

Note: <r:site_name />is depreciated and should not be used.

site.{attr}

Use this tag to get properties about the current site, where {attr} is replaced by one of the attributes listed below.

Attribute options

id - Get the site ID

name - Get the site name

root_page - Get the root page of the site (Note: this is not the homepage and is hidden to all users). Returns an array.

domain - Get the domain for the site. Returns: example.wvu.edu.

url: Get the canonical URL for the site. Returns: https://example.wvu.edu

first_random_image_tagged_with - Get a random image that has been tagged with the specified label. See Get a random image, file, or blog article for more information.

background_styler - Add a background image via inline CSS. The background image must have a label and will be output with dimensions of 1780x1780. See Get a random image, file, or blog article for more information.

get_page - Get a specific page via it's ID. See the documentation for get_page .

pages - Returns an array of every page in your site. See the documentation for r:page:{attr} .

base_pages - Get an array of the pages at the top/root level of a site.

get_file - Get a file via file ID. Find a file's ID by going to Files and hovering over the preview. The ID will show up in the title text. See r:get_file for more information on this tag.

files - Get an array of all the files in a site. See the documentaiton for r:files .

images - Get an array of all the images in a site.

data - Access Custom Site Data. See our documentation for Custom Site Data.

Examples

Get a site ID:

{{ site.id }}

☝️ You can use this format for id, name, domain and url.

Access Custom Site Data:

{{ site.data.my_site_data_name }}
<!-- OR -->
{{ site.data["my_site_data_name"] }}

Get a specific page using get_page:

{% assign pages = site.pages | get_page: 77 %}
{% for page in pages.all %}
  <p>{{ page.name }}</p>
{% endfor %}

Make a list of all pages at the top level of a site:

{% assign rootPages = site.base_pages %}
<ul>
  {% for page in rootPages.all %}
    <li>
      <a href="{{ page.url }}">{{ page.name }}</a>
    </li>
  {% endfor %}
</ul>

Get one random page that has any of the following labels:

{% assign pages = site.pages | filter_pages: labels: "test-label,a-label", limit: 1, random: true %}
<ul>
  {% for page in pages.all %}
    <li>
      <a href="{{ page.url }}">{{ page.name }}</a>
    </li>
  {% endfor %}
</ul>

Get a list of labelled images:

<!-- Only returns images due to `site.images`: -->
{% assign images = site.images | filter_files: tags: "tag1,tag2,backpage-1-thumbnail", tags_match: "any" %}
<ul>
  {% for image in images.all %}
    <li>
      <a href="{{ image | image_url }}">
        <img src="{{ image | image_url: size: "250x250" }}" alt="{{ image.alt_text }}" />
      </a>
    </li>
  {% endfor %}
</ul>

Last updated on March 19, 2021.

We welcome all questions, feedback and bug reports. If you're having an issue, we usually need the following information:

  • A brief description of the issue
  • A link to the page where you saw the issue
  • Screenshots that illustrate the problem - How do I take a screenshot?

Kindly email CleanSlate@mail.wvu.edu for help or use the form on the request help page.