diff -u b/core/modules/system/templates/links.html.twig b/core/modules/system/templates/links.html.twig
--- b/core/modules/system/templates/links.html.twig
+++ b/core/modules/system/templates/links.html.twig
@@ -38,20 +38,20 @@
- {% if heading.level %}
+ {%- if heading.level -%}
<{{ heading.level }}{{ heading.attributes }}>{{ heading.text }}{{ heading.level }}>
- {% else %}
+ {%- else -%}
{{ heading.text }}
- {% endif %}
- {% endif %}
+ {%- endif -%}
+ {%- endif -%}
- {% for item in links %}
+ {%- for item in links -%}
-
- {% if item.link %}
+ {%- if item.link -%}
{{ item.link }}
- {% elseif item.text_attributes %}
+ {%- elseif item.text_attributes -%}
{{ item.text }}
- {% else %}
- {{ item.text }}
- {% endif %}
+ {%- else -%}
+ {{- item.text -}}
+ {%- endif -%}
{%- endfor -%}
-{%- endif %}
+{%- endif -%}
diff -u b/core/themes/classy/templates/navigation/links.html.twig b/core/themes/classy/templates/navigation/links.html.twig
--- b/core/themes/classy/templates/navigation/links.html.twig
+++ b/core/themes/classy/templates/navigation/links.html.twig
@@ -36,20 +36,20 @@
- {% if heading.level %}
- <{{ heading.level }}{{ heading.attributes }}>{{ heading.text }}{{ heading.level }}>
- {% else %}
- {{ heading.text }}
- {% endif %}
- {% endif %}
+ {%- if heading.level -%}
+ <{{ heading.level }}{{ heading.attributes }}>{{- heading.text }}{{ heading.level }}>
+ {%- else -%}
+ {{- heading.text }}
+ {%- endif -%}
+ {%- endif -%}
- {% for item in links %}
+ {%- for item in links -%}
-
- {% if item.link %}
+ {%- if item.link -%}
{{ item.link }}
- {% elseif item.text_attributes %}
- {{ item.text }}
- {% else %}
- {{ item.text }}
- {% endif %}
+ {%- elseif item.text_attributes -%}
+ {{- item.text }}
+ {%- else -%}
+ {{- item.text -}}
+ {%- endif -%}
- {% endfor %}
+ {%- endfor -%}
-{%- endif %}
+{%- endif -%}