Anchor links to views grouping field titles I want to make a table of content block where I link to the grouping field titles on a view. The problem is that the grouping field is only a h3 without any class or id. Is there a way to nest the h3 in a div with an unique ID so I can create an anchor link for it?
I think this may be a template modification task.

This is the current views-view-unformatted.html.twig file:

{% if title %}
  &lt;h3&gt;{{ title }}&lt;/h3&gt;
{% endif %}
{% for row in rows %}
  {%
    set row_classes = [
      default_row_class ? 'views-row',
    ]
  %}
  &lt;div{{ row.attributes.addClass(row_classes) }}&gt;
    {{ row.content }}
  &lt;/div&gt;
{% endfor %}


Switch:

&lt;h3&gt;{{ title }}&lt;/h3&gt;


With:

&lt;h3 id="{{ title | clean_class }}"&gt;{{ title }}&lt;/h3&gt;


This would require your titles to all be unique to ensure unique ID's. There may be something better to use than "title" for the ID as well in this case.

Also, I would wonder if using an "attachment" in the view might give better options and control over a block for the table of contents...