Write some code to achieve what you need. Here I have written a simple solution for you. Try it, it should do what you want
<script type="text/x-handlebars" data-template-name="/connectors/discovery-list-controls-above/tag-h2">
<h2>
{{#if h2_tag}}
{{h2_tag}}
{{/if}}
</h2>
</script>
<script type="text/discourse-plugin" version="0.8">
api.registerConnectorClass("discovery-list-controls-above", "tag-h2", {
setupComponent(args, component) {
if (window.location.pathname?.startsWith("/tag/"))
component.set("h2_tag", /\/tag\/([^?]+)/.exec(decodeURI(window.location.pathname)).at(1));
},
});
</script>