Link
The page
object has the following attributes:
- page.id
- page.name
- page.display_order
- page.description
- page.created_at
- page.updated_at
- page.url
- page.active?
page.url
Returns url of the page.
Input
<ul>
{% for page in listing.instant_website.pages %}
<li>
<a href="{{ page.url }}">{{ page.name }}</a>
</li>
{% endfor %}
</ul>
Output
<ul>
<li>
<a href="/">Home</a>
</li>
<li>
<a href="/about_us">About Us</a>
</li>
</ul>
page.active?
Returns true if current request match current path.
For the common use case of using active?
is for toggle class value of HTML element.
Input
<ul>
{% for page in listing.instant_website.pages %}
<li>
<a href="{{ page.url }}" class="{{ 'active' | toggle_class_name: page.active? }}">{{ page.name }}</a>
</li>
{% endfor %}
</ul>
Output
<ul>
<li>
<a href="/" class="active">Home</a>
</li>
<li>
<a href="/about_us" class="">About Us</a>
</li>
</ul>