const collections = [
{categoryLink: '/blog/category/', canonicalLink: 'https://your-domain/blog/'}
]
collections.forEach(({categoryLink, canonicalLink})=> {
if(window.location.pathname.includes(categoryLink)) {
const squarespaceSetCanonical = document.querySelector("link[rel='canonical']")
if(squarespaceSetCanonical) {
squarespaceSetCanonical.remove()
}
const linkTag = document.createElement('link');
linkTag.setAttribute('rel', 'canonical');
linkTag.href = canonicalLink
document.head.appendChild(linkTag)
}
})