Replace Links with Custom URLs
What You'll Create
A JavaScript utility for your Squarespace site that automatically replaces link destinations based on a URL pattern. Any link containing replace-url- in its href will be redirected to the URL specified after that keyword, enabling external linking from elements that normally only link internally.
The Problem It Solves
Many Squarespace elements (summary blocks, product items, portfolio grids) only allow linking to internal pages or use auto-generated URLs. There's no native way to redirect these to external sites or custom destinations. This script provides a workaround using a simple naming convention.
Perfect For
External product links, affiliate redirects, summary block external URLs, portfolio external links, custom navigation destinations.
What Makes This Different
Finds all matching links containing the keyword, then extracts the destination URL by splitting at that point. The script processes all matching links when the page loads. Clean, dependency-free code that works instantly without jQuery.
Details
Section Type: Fluid & Classic
Code Type: JavaScript
Prerequisites: Footer code injection access
Toolkit Title: Replace Links
Learn This Technique
This is one of 150+ code techniques taught inside Standout Squarespace, where you get:
The complete, copy-paste code
Video walkthrough explaining how it works
The principles behind the technique so you can customize it
Access to our private community for support

