How can I display filenames in a Squarespace Gallery Block?

There are many situations when you may want to display image filenames below images in a Gallery Grid block. This is particularly useful for photographers who may create a page in Squarespace for their client to view. Here's how to do it with a page of Gallery thumbnails.

Create a new page.

Add a Gallery Block to the page. Choose the Grid option.

Upload your images to the Gallery Block, or if they are already in a Gallery Page you can click on Use Existing Gallery and select the one you want. This avoids uploading them again.

On the Design tab, format the Gallery how you'd like it to display, i.e. the aspect ratio, the number of thumbnails per row, etc.

It's essential that you tick the Show Title check box. If you don't do this, you won't see the filenames!

Apply the settings and save the page.

In the Settings for this page (click the gear icon next to the page name) click the Advanced tab. In the PAGE HEADER CODE INJECTION box, paste the following code:

<script src="" integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh" crossorigin="anonymous"></script>
  window.Squarespace.onInitialize(Y, function(){
    $('.slide img').each(function(i) {
      $('.image-slide-title').eq(i).html('' + $(this).attr('alt').replace('.jpg', '') + '');

Save your settings and when the page is refreshed you'll see the filenames below them. You can change the filename formatting if you’d like.

Note that if you enter a formal title for an image (in the Gallery image properties) it will replace the filename. The code also removes .jpg extensions.

Is this the best solution? No, it’s just an example. If you want a robust solution for your Squarespace website that loads more quickly, you can book us to build one for you.

If your filenames are too long when shown on mobile, you may need to add some styling to the Custom CSS area to avoid them clipping. For example:

.sqs-gallery-block-grid.sqs-gallery-block-meta-only-title .margin-wrapper .image-slide-title {
  line-height: 1.2em;
  white-space: pre-wrap;
  overflow: visible;