I am working on the Autotrust website and for one of their page templates I needed to create a menu item which shows the current page and redirects to the current page URL.
The main idea is to add this as menu item
<a href="{{ content.absolute_url }}" target="_self">{{ content.name }}</a>
This solution is not working because the menu structure is based on labels not the modules so I used this solution: I added this as the menu item
U bent hier: <a href="#" id="current-page-link"></a>
Then I use the code below in the page footer to use JS to get the page name and URL
<script>
document.addEventListener("DOMContentLoaded", function() {
var currentPageLink = document.getElementById("current-page-link");
if (currentPageLink) {
currentPageLink.href = window.location.href;
currentPageLink.textContent = document.title;
}
});
</script>