Evergreen Filterable Gallery
A photo gallery with category filter buttons and a lightbox, for any website. One small script, no dependencies.
Keep your photos in a Google Sheet (or a CSV file, or plain HTML). Add a row with the photo link and a category, and the gallery, its filter buttons and the lightbox update on their own.
What's in the download
| File or folder | What it's for |
|---|---|
INSTALL.md | Step-by-step setup for Squarespace (every plan), WordPress, Wix, Webflow, Shopify, Ghost, Carrd and plain HTML |
templates/gallery-template.csv | Spreadsheet template. Open it in Google Sheets or Excel. |
embed/ | Ready-to-paste snippets. Start here. |
evergreen-gallery.zip | The WordPress plugin. Upload it under Plugins → Add New → Upload Plugin. |
dist/filterable-gallery.min.js | The compact script. Use it if you upload the file to your site. |
dist/filterable-gallery.js | The readable script, for anyone who wants to look inside |
demo/index.html | Double-click to try it offline |
LICENSE.txt | What your license allows |
The whole idea in two lines
<div data-filterable-gallery data-src="YOUR-PUBLISHED-GOOGLE-SHEET-CSV-LINK"></div>
<script src="filterable-gallery.min.js" defer></script>
Every option is another data- attribute on that div. See Options in INSTALL.md.
For developers
Galleries start automatically, including ones added to the page later (Squarespace AJAX pages, page builders, tabs).
EvergreenGallery.init(); // start any new galleries on the page
galleryDiv.__egg.filter("Kitchens"); // switch category ("" = All)
Questions or installation help: use the contact page at evergreencode.store.
Installation
Every install has the same two parts:
- Your photos: listed in a Google Sheet (recommended), rows pasted into the page, or plain
<img>tags. - The snippet: one of the files in
embed/, pasted where you want the gallery.
Step 1: Put your photos online
Each photo needs a web address (a link ending in .jpg, .png or .webp, or a Google Drive link).
- Squarespace: edit any text block, highlight a word, click the link icon, then File → Upload file. Each photo gets an address like
/s/kitchen.jpg. Remove the temporary link afterward. - WordPress: use the plugin (below). It reads your Media Library directly, so you can skip the spreadsheet.
- Google Drive: upload the photo, click Share → General access → Anyone with the link, and copy the link. The gallery converts Drive links into image links automatically.
- Anywhere else: your site's media or file manager.
Wide photos load faster when resized to about 1600 pixels across. A smaller copy for the grid (about 600 pixels) makes the page even faster; put it in the Image column and the large one in Full image.
Step 2: Make your photo list (Google Sheet)
- Go to sheets.google.com, then File → Import → Upload and choose
templates/gallery-template.csv. - Replace the example rows with your photos. One row per photo:
| Column | What goes in it |
|---|---|
| Image (required) | The photo link shown in the grid |
| Full image | A larger version for the lightbox. Leave empty to use the Image link. |
| Category | The filter button(s) it appears under. Separate several with commas: Kitchens, Remodels |
| Caption | Text under the photo and in the lightbox |
| Alt text | A description for screen readers and search engines. Leave empty to use the caption. |
| Link | Optional page link shown in the lightbox, such as a project write-up |
Column names aren't picky: "Photo", "Title", "Project type" and similar names also work. Filter buttons appear in the order categories first show up in your list, with All first.
- Click File → Share → Publish to web.
- Under Link, choose your sheet tab, change "Web page" to Comma-separated values (.csv), and click Publish.
- Copy the link it shows. It contains
/pub?and ends inoutput=csv.
Use this link, not the address in your browser bar. A link ending in /edit won't work, and the gallery will tell you so if you paste one by mistake. After publishing, changes in the sheet appear on your site within about 5 minutes.
No spreadsheet? Use embed/2-pasted-data-embed.html and type your rows straight into the snippet, or put <img> tags inside the gallery:
<div data-filterable-gallery>
<img src="/s/kitchen.jpg" data-category="Kitchens" alt="White kitchen with island">
<img src="/s/patio.jpg" data-full="/s/patio-large.jpg" data-category="Outdoor" data-caption="Backyard patio" alt="Stone patio">
</div>
Step 3: Choose a snippet
File in embed/ | Use it when |
|---|---|
1-google-sheet-embed.html | One paste that does everything: your sheet link plus the script. Easiest. |
2-pasted-data-embed.html | You'd rather type your photos into the snippet than use a sheet. |
3-site-wide-script.html | Your builder has a site-wide footer code box. Paste it there once. |
4-gallery-only.html | The script is already loaded (by file 3 or the hosted file) and you're adding a gallery. |
5-hosted-file-embed.html | You can upload files to your site and want the shortest code. |
Most builders only run custom code on the published page. If you see a blank box or code while editing, check the live page or preview.
Squarespace
Works on Squarespace 7.1 and 7.0, in any template, on every plan.
Core, Plus or Advanced plans (legacy Business and Commerce)
One gallery: add a Code Block, paste embed/1-google-sheet-embed.html, and put in your sheet link.
Several galleries: paste embed/3-site-wide-script.html into Settings → Advanced → Code Injection → Footer (or Website → Pages → Custom Code → Code Injection) once. Then add a Code Block with embed/4-gallery-only.html wherever you want a gallery.
In Fluid Engine, drag the Code Block's corner to make it as wide as you want.
Basic plan (legacy Personal): no upgrade needed
Basic and Personal plans don't run Code Blocks or Code Injection, but Markdown Blocks accept HTML on every plan.
This is a widely used workaround, but Squarespace doesn't officially support it and could change how Markdown Blocks behave in the future.
- Upload the script file. Use the link → File → Upload file trick to upload
dist/filterable-gallery.min.js. It will be at/s/filterable-gallery.min.js. - Load it from your footer. Click Edit, hover over the footer, click Edit Footer, add a Markdown block and paste: ``
html <script src="/s/filterable-gallery.min.js" defer></script>`` The block looks empty on the page. That's normal. If your site has no footer, put this line in a Markdown block on each page that has a gallery. - Add the gallery. Add a Markdown block where the gallery should go and paste the line from
embed/4-gallery-only.htmlwith your sheet link. Keep it on one line.
Use the Google Sheet method with Markdown blocks. Don't paste the whole script or long lists of photos into a Markdown block, because Markdown can change symbols in them.
WordPress
Works with the Block Editor, Classic Editor, Elementor, Divi, Beaver Builder and any theme. Needs WordPress 5.8+ and PHP 7.4+.
- Go to Plugins → Add New → Upload Plugin, choose
evergreen-gallery.zip, click Install Now, then Activate. - In Media → Library, click each photo you want in the gallery and fill in the new Gallery categories field, for example
KitchensorKitchens, Remodels. Captions and alt text come from the same screen. - Add a Shortcode block and paste: ``
[evergreen_gallery]
That shows every photo that has a gallery category. Other ways to choose photos:
- Only some categories:
[evergreen_gallery category="Kitchens, Bathrooms"] - Exact photos, in order:
[evergreen_gallery ids="12,15,18,22"](the number afteritem=in the address bar when you click a photo in the Media Library) - A Google Sheet:
[evergreen_gallery src="YOUR-PUBLISHED-CSV-LINK"]
Shortcode options: columns, mobile_columns, layout, ratio, gap, filters, captions, lightbox, page_size, start, accent, align, class (same as the options below, with _ instead of -), plus size (grid image size, default medium_large) and full_size (lightbox size, default large).
[evergreen_gallery columns="4" ratio="1/1" captions="overlay" page_size="12"]
The photos are written into the page as normal images, so search engines can see them, and the script only loads on pages that have a gallery.
If a caching or speed plugin breaks the gallery, exclude filterable-gallery.min.js from its "delay JavaScript" or "combine JS" settings.
Wix
Add Embed Code → Embed HTML, paste embed/1-google-sheet-embed.html, and put in your sheet link. Drag the element tall enough for your gallery. Wix shows embeds in a frame, so photos open in the lightbox inside that frame.
Webflow
Paste embed/3-site-wide-script.html into Site settings → Custom code → Footer code once, then add an Embed element with embed/4-gallery-only.html. Custom code needs a paid site plan.
Shopify
Online Store 2.0 themes: add a Custom Liquid section and paste embed/1-google-sheet-embed.html.
Ghost
Add an HTML card and paste embed/1-google-sheet-embed.html. For many galleries, paste embed/3-site-wide-script.html into Settings → Code injection → Site Footer once and use embed/4-gallery-only.html in each card.
Carrd
Add an Embed element, set its type to Code, and paste embed/1-google-sheet-embed.html. Embeds need a Carrd Pro plan.
Any website (HTML)
Upload dist/filterable-gallery.min.js and use embed/5-hosted-file-embed.html.
Options
Add any of these to the <div data-filterable-gallery …> tag:
| Attribute | What it does | Example |
|---|---|---|
data-src | Your published Google Sheet (CSV) or CSV file link | data-src="https://docs.google.com/…output=csv" |
data-columns | Columns on wide screens (default 3) | data-columns="4" |
data-mobile-columns | Columns on phones (default 2) | data-mobile-columns="1" |
data-layout | grid crops photos to one shape; masonry keeps each photo's own shape | data-layout="masonry" |
data-ratio | Photo shape in the grid layout (default 4/3) | data-ratio="1/1" |
data-gap | Space between photos in pixels (default 12) | data-gap="6" |
data-filters | buttons (default), dropdown, or none | data-filters="dropdown" |
data-start | The category shown first (default All) | data-start="Kitchens" |
data-captions | below (default), overlay (on hover), or none | data-captions="overlay" |
data-lightbox | false to turn off the lightbox; photos with a Link open it instead | data-lightbox="false" |
data-page-size | Show this many photos, then a Show more button | data-page-size="12" |
data-accent | Color of the selected filter button | data-accent="#1d5c45" |
data-align | center to center the filter buttons | data-align="center" |
data-text-all | Rename the All button | data-text-all="Everything" |
data-text-show-more | Rename the Show more button | data-text-show-more="Load more" |
Styling
Add to your site's custom CSS (Squarespace: Design → Custom CSS, available on every plan; WordPress: Appearance → Customize → Additional CSS):
[data-filterable-gallery] {
--egg-accent: #1d5c45; /* selected filter button */
--egg-on-accent: #ffffff; /* text on the selected button */
--egg-radius: 8px; /* photo corners; 0 for square */
--egg-gap: 12px; /* space between photos */
}
The gallery uses your site's font and text color automatically.
Troubleshooting
"The gallery couldn't load its photos." On your live site this message stays general. Open the page in the Squarespace editor or WordPress preview, or open your browser's console, to see the exact reason. The most common one is a Google Sheet link that isn't the Publish to web → CSV link.
A photo is missing. Its link is empty, misspelled, or isn't a direct image link. Open the link in a new tab: you should see only the photo.
Changes in my sheet don't show up. Google refreshes published sheets every few minutes. Wait, then reload.
The code shows up as text. On Squarespace, use a Markdown block (not a Text block) and keep the gallery on one line. In WordPress, use a Shortcode or Custom HTML block.
Still stuck? Use the contact page at evergreencode.store. Installation help is included for 6 months.
Changelog
1.0.0 (2026-10-30)
First release.
- Photo gallery with category filter buttons (or a dropdown), built automatically from your categories.
- Photos from a Google Sheet, a CSV file, rows pasted into the page, or plain
<img>tags. - Grid (cropped to one shape) or masonry layout; columns, gap, captions below or on hover, "Show more" paging, starting category.
- Lightbox with previous/next, arrow keys, swipe, photo counter, captions and optional project links.
- Google Drive share links work as image links.
- WordPress plugin:
[evergreen_gallery]shortcode and a "Gallery categories" field on each Media Library photo. - Install guides for Squarespace (every plan, including Basic/Personal via Markdown Blocks), WordPress, Wix, Webflow, Shopify, Ghost, Carrd and plain HTML.
- Keyboard and screen-reader support; respects reduced motion; shielded from site-wide styles.