Jump to content

Change portfolio items all listed as h1 to h2

Recommended Posts

I'm not sure why but Squarespace codes all portfolio list items as h1. This is horrible for SEO. Plus there should be an actual h1 on the page with some body copy. Here's some code to change the list items to h2. Paste into header code injection area.

<script>
document.addEventListener("DOMContentLoaded", function() {
    var headings = document.querySelectorAll('h1.portfolio-hover-item-title');
    headings.forEach(function(heading) {
        var newHeading = document.createElement('h2');
        newHeading.className = heading.className;
        newHeading.innerHTML = heading.innerHTML;
        heading.parentNode.replaceChild(newHeading, heading);
    });
});
</script>
 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.