How to Add a Filterable Portfolio Gallery to Squarespace
October 30, 2026 · 4 min read
If your work falls into categories, like kitchens, baths and outdoor projects, or weddings, portraits and events, visitors want to see the kind they came for. A single long gallery makes them scroll past everything else to find it.
Squarespace's Gallery Blocks and gallery sections look good, but they can't be filtered by category. This guide covers the common workarounds, free code for filter buttons, and an option that keeps your gallery in a Google Sheet.
What Squarespace offers today
- Gallery Blocks and gallery sections show a grid, masonry, slideshow or carousel of photos, with a lightbox. There's no category filter.
- Separate gallery pages per category (a "Kitchens" page, a "Baths" page). This works, but visitors can't see everything at once, and you maintain several pages.
- A portfolio or blog collection with categories. Blog categories can be filtered by address, but each "photo" becomes a post, which is a lot of work for a gallery.
If you have a handful of categories and want visitors to switch between them on one page, filter buttons are the cleanest answer.
Step 1: Organize your photos
Before any code, decide your categories. Good gallery categories:
- Match what people are looking for, not your internal job codes: "Kitchens", not "Interior remodel – Type B".
- Number from three to six. More than that and the buttons become a menu nobody reads.
- Can overlap. A kitchen-and-dining project can sit in both.
Then resize your photos. About 600 pixels wide is plenty for the grid, and 1600 pixels for the full-size view. Upload them (see the file upload trick) so each has a link.
The free way: filter buttons in a Code Block
This works on Core, Plus and Advanced plans (and legacy Business and Commerce), because it uses a little JavaScript. Add a Code Block, set it to HTML, and paste:
<div class="fg">
<p>
<button type="button" data-filter="all">All</button>
<button type="button" data-filter="kitchens">Kitchens</button>
<button type="button" data-filter="outdoor">Outdoor</button>
</p>
<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:12px">
<img src="/s/kitchen-1.jpg" data-cat="kitchens" alt="White kitchen with island" style="width:100%;aspect-ratio:4/3;object-fit:cover">
<img src="/s/patio-1.jpg" data-cat="outdoor" alt="Stone patio with fire pit" style="width:100%;aspect-ratio:4/3;object-fit:cover">
</div>
</div>
<script>
document.querySelectorAll(".fg").forEach(function (g) {
g.addEventListener("click", function (e) {
var f = e.target.getAttribute("data-filter");
if (!f) return;
g.querySelectorAll("[data-cat]").forEach(function (img) {
img.style.display = f === "all" || img.getAttribute("data-cat") === f ? "" : "none";
});
});
});
</script>
Add one <img> line per photo, with its category in data-cat (lowercase, matching a button's data-filter). Add one button per category.
What it doesn't do: photos can only be in one category, there's no full-size view (lightbox), the buttons don't show which one is selected, and every new photo means editing the code. It's a fine start for a dozen photos that rarely change.
Keeping the gallery in a Google Sheet
Once a gallery grows, editing code for every new photo gets old. A better setup is a Google Sheet with one row per photo:
| Image | Full image | Category | Caption |
|---|---|---|---|
| /s/kitchen-1-small.jpg | /s/kitchen-1.jpg | Kitchens | Smith kitchen remodel |
| /s/patio-1-small.jpg | /s/patio-1.jpg | Outdoor, Patios | Backyard patio |
The gallery reads the sheet, builds the filter buttons from the Category column, and updates whenever you add a row. Anyone on your team can add photos without touching the website. See How to Show a Google Sheet on Your Website for how publishing a sheet works.
On the Basic or Personal plan
Basic plans don't run JavaScript in Code Blocks, so the free version shows the photos, but the buttons won't filter. You can upgrade to Core, or load a gallery script from an uploaded file through a Markdown Block, a widely used workaround. How to add custom code to Squarespace without upgrading walks through it.
Gallery tips for Squarespace
- Give the gallery room. A full-width section with three columns on desktop works for most portfolios. Phones should show two.
- Lead with your best work. The first row decides whether visitors keep scrolling.
- Use captions sparingly but usefully: the project, the place, or the one detail that makes it special.
- Write alt text for every photo. It helps visitors who can't see the images, and helps search engines understand them.
- Link to the full story. If a project has a write-up, link it from the photo's full-size view.
The ready-made option
The Filterable Gallery is the spreadsheet-driven version, built for Squarespace:
- Filter buttons (or a dropdown) built from your categories, with photos in several categories at once
- A lightbox with arrows, swipe on phones and keyboard support, captions, and an optional link to each project
- Grid or masonry layout, columns, photo shape, captions below or on hover, and a "Show more" button for big portfolios
- Photos from a Google Sheet, rows pasted into the page, or plain image tags. Google Drive links work too.
- Works on every Squarespace plan, with instructions for Code Blocks and the Markdown Block method on Basic, plus a WordPress plugin that adds a "Gallery categories" field to your Media Library
It's $29 once, for unlimited sites, including client sites. Try the live demo.
Want to try the settings first? The free filterable gallery builder shows your choices live and writes the code for you.