dynamic

Table of contents

Heads up! The dynamic tag only works if caching is enabled for the site. If caching is disabled, the dynamic tag doesn't do anything.

The dynamic block excludes everything inside from caching. The code inside the dynamic block is parsed on every request, even when caching is enabled. This way you can cache your pages, and at the same time keep parts of the code dynamic.

Vul hier uw eigen inhoud in.

<!-- This timestamp is cached, so always returns the time when cache occurred -->
Cached time: {{ "now" | date: "%Y-%m-%d %H:%M" }}

{% dynamic %}
  <!-- inside dynamic, so always returns the current time -->
  Current time: {{ "now" | date: "%Y-%m-%d %H:%M" }}
{% enddynamic %}
Input
<!-- This timestamp is cached, so always returns the time when cache occurred -->
Cached time: 2020-01-02 14:08

<!-- inside dynamic, so always returns the current time -->
Current time: 2020-01-06 14:08
Output

It is not necessary to put both setting and getting of variables inside the dynamic block. The following code will work:

{% assign blog_posts = site.blog_posts %}
{% dynamic %}
  {% for post in blog_posts %} {{ post.title }} {% endfor %}
{% enddynamic %}

Need help?

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