代码如下:
<body>
{% set links = [
('home',url_for('.home')),
('service',url_for('.service')),
('about',url_for('.about')),
] %}
<nav>
{% for label,link in links %}
{% if not loop.first %}|{% endif %}
<a href="{% if link is current_link %}#
{% else %}
{{ link }}
{% endif %}
">{{ label }}</a>
{% endfor %}
</nav>
</body>效果如下:

参考:
https://www.cnblogs.com/wongbingming/p/6807771.html