Advanced dynamic templates: lists, objects, conditions and helpers
If you’re already using basic templates like:
{{post.title}}
{{post.excerpt}}
you can take things further using:
- sections (for objects and lists)
- conditional output
- helpers (for formatting)
This guide focuses on real-world usage without getting too theoretical.
Sections: the core concept
Sections are written like this:
{{#variable}}
...content...
{{/variable}}
They behave differently depending on the data type:
| Type | Behavior |
|---|---|
| boolean | renders only if true |
| object | gives access to its fields |
| list | loops over items |
Booleans (conditional output)
Use sections to show content only when a value exists or is true.
Example
{{#acf.subtitle}}
{{acf.subtitle}}
{{/acf.subtitle}}
If the field is empty, nothing is shown.
Practical example
{{post.title}}
{{#acf.event_date}}
Date: {{acf.event_date}}
{{/acf.event_date}}
Objects
Objects contain multiple fields.
Example
{{#wc.product}}
{{title}}
{{price}}
{{/wc.product}}
Inside the section, you can reference fields directly.
Alternative
{{wc.product.title}}
{{wc.product.price}}
Use sections when you need multiple fields from the same object.
Lists (arrays)
Lists allow you to loop over multiple items.
Example
{{#reviews}}
- {{author}}: {{text}}
{{/reviews}}
Each item in the list is rendered once.
Simple lists
{{#tags}}
{{.}}
{{/tags}}
{{.}} refers to the current item.
Combining structures
You can combine sections for more control.
{{#wc.product}}
{{title}}
{{#price}}
Price: {{price}}
{{/price}}
{{/wc.product}}
Helpers
Helpers let you modify text inside a section.
They follow the same structure:
{{#helper}}
...content...
{{/helper}}
upper
Convert text to uppercase.
{{#upper}}
{{post.title}}
{{/upper}}
lower
Convert text to lowercase.
{{#lower}}
{{post.title}}
{{/lower}}
ucfirst
Capitalize the first letter.
{{#ucfirst}}
{{post.title}}
{{/ucfirst}}
oneline
Remove line breaks and extra spacing.
{{#oneline}}
{{post.content}}
{{/oneline}}
Useful for keeping posts compact.
Combining helpers
Helpers can be nested:
{{#upper}}
{{#oneline}}
{{post.title}}
{{/oneline}}
{{/upper}}
Handling empty values
If a variable is empty:
- nothing is output
- sections are skipped
Safe pattern
{{#acf.subtitle}}
{{acf.subtitle}}
{{/acf.subtitle}}
Practical examples
Event post
{{post.title}}
{{#acf.event_date}}
Date: {{acf.event_date}}
{{/acf.event_date}}
{{#acf.event_location}}
Location: {{acf.event_location}}
{{/acf.event_location}}
{{post.excerpt}}
Product promotion
{{#wc.product}}
{{title}}
Price: {{price}}
{{url}}
{{/wc.product}}
Tags or categories
{{#post.categories}}
#{{.}}
{{/post.categories}}
Compact version
{{#oneline}}
{{post.excerpt}}
{{/oneline}}
Common mistakes
Using objects without sections
Incorrect:
{{wc.product}}
Correct:
{{#wc.product}}
{{title}}
{{/wc.product}}
Expecting output from empty values
If a field is empty:
{{acf.field}}
Nothing will be shown.
Overcomplicating templates
Keep templates readable. Google Business posts are short, so simple usually works best.
Tips
- Use sections for optional content
- Use helpers for formatting
- Use preview to test your templates
- Start simple, then expand
Compatibility
Dynamic templates work with:
Old %variables% still work
The previous %variable% system is still supported.
You don’t need to change anything, but the new system gives you more flexibility.
Getting started
- Open your template settings
- Insert variables using the browser
- Add sections or helpers if needed
- Preview the result
- Save
Final note
You don’t need all of this for most use cases.
But when you need more control, sections and helpers let you build flexible templates without complicated logic.