How do I theme a link from a template file?
Here's a twig only solution for a particular field that needs this treatment;
it's not a generic solution for all links everywhere.

some-template.twig:

&lt;ul class="field--name-field-links"&gt;
  {% for item in content.field_links %}
  {% if item['#title'] %}
    &lt;li&gt;
      &lt;a href="{{ item['#url'] }}" class="{{ item['#options'].attributes.class|join(' ') }}" &gt;
        {% if item['#options']['attributes']['class'] %}
          &lt;span class="sprite {{ item['#options']['attributes']['class']|join(" ") }}"&gt;&lt;/span&gt;
        {% endif %}
        {{ item['#title'] }}
      &lt;/a&gt;
    &lt;/li&gt;
  {% endif %}
  {% endfor %}
&lt;/ul&gt;