The “Expected end of tag” error in Power Pages (Power Apps Portals) is a Liquid parsing error that usually happens when the syntax of a tag, loop, or block is not correctly closed or structured.
This guide will explain:
- What this error means
- Common causes
- Step-by-step debugging process
- Examples and fixes
What Does “Expected End of Tag” Mean?
This error is thrown when Liquid’s parser expects the end of a tag block (like endif
, endfor
, endfetchxml
) but doesn’t find it or encounters a malformed structure.
Common Causes
- Missing closing tag (e.g.,
endif
,endfor
) - Incorrect tag spelling (e.g.,
endforr
,endfechxml
) - Extra/misplaced
{%
or%}
syntax - Nested blocks not closed in the right order
- Using
{{ }}
instead of{% %}
for logic tags
Example Scenarios and Fixes
1. Missing endif
Incorrect:
{% if user %}
Welcome {{ user.fullname }}
Fix:
{% if user %}
Welcome {{ user.fullname }}
{% endif %}
2. Spelling Error in Closing Block
Incorrect:
{% for item in items %}
{{ item.name }}
{% endforr %}
Fix:
{% for item in items %}
{{ item.name }}
{% endfor %}
3. Mismatched Logic Tags
Incorrect:
{{ if user }}
Hello
{% endif %}
{{ }}
is used for output.{% %}
should be used for logic.
Fix:
{% if user %}
Hello
{% endif %}
4. Nested Tags Closed Improperly
Incorrect:
{% if user %}
{% for order in orders %}
{{ order.name }}
{% endif %}
{% endfor %}
- The tags are closed in the wrong order.
Fix:
{% if user %}
{% for order in orders %}
{{ order.name }}
{% endfor %}
{% endif %}
5. FetchXML Block Improperly Closed
Incorrect:
{% fetchxml cases %}
<fetch>
<entity name="incident">
<attribute name="title" />
</entity>
</fetch>
{% endfetch %}
Fix:
{% fetchxml cases %}
<fetch>
<entity name="incident">
<attribute name="title" />
</entity>
</fetch>
{% endfetchxml %}
Debugging Strategy
- Use Visual Alignment: Match each
{% if %}
,{% for %}
,{% fetchxml %}
with the correspondingend
tag. - Indentation: Helps catch mismatches in nested logic.
- Comment Out Blocks: Temporarily isolate the error.
- Build from Small Blocks: Start with simple tags and expand logic slowly.
Best Practices
- Always close logic tags explicitly.
- Avoid using
{{ }}
for conditional blocks or loops. - Don’t mix output and logic tags.
- Recheck the spelling of
endfor
,endif
,endfetchxml
, etc. - Use a code editor with Liquid syntax highlighting for easier debugging.