{% if theme_announcement %}
{#- `pathto('/' + pagename)` - pathto() needs absolute path, but pagename returns string without "/" But `pathto('/' + pagename)` produces double slashes in the URL (e.g. //index.html). So we need to strip leading slash with `lstrip('/')`. -#} {%- set pagename_url = pathto('/' + pagename).lstrip('/') -%} {{ theme_announcement.replace("$PAGE$", pagename_url) | safe }}
{% endif %}