// set the og:url same as the canonical url window.addEventListener('DOMContentLoaded', (event) => { let canonicalTag = document.querySelector('link[rel="canonical"]'); let canonicalURL = canonicalTag ? canonicalTag.getAttribute('href') : window.location.href; let metaTag = document.querySelector('meta[property="og:url"]'); if (!metaTag) { metaTag = document.createElement('meta'); metaTag.setAttribute('property', 'og:url'); document.head.appendChild(metaTag); } metaTag.setAttribute('content', canonicalURL); });