Wikidown

Home / Getting Started / Photo Galleries

Photo Galleries

Turn a set of photos on a page into a gallery: a grid of thumbnails that opens a full-screen viewer on the published site. It takes a few lines of _config.yml and plain HTML in the page. New in 0.15.0.

What it is and when to use it

The gallery is a web component, a custom HTML tag (<wikidown-gallery>) that a small script brings to life in the browser. Wikidown has one built into its starter theme. Use it for photo sets on a venue, event, product or project page.

The page keeps ordinary HTML, so nothing is lost where scripts don't run. On github.com, in the web editor's preview, and with JavaScript off, readers see the photos with their alt text, and each one links to the full image.

1. Turn it on

Add this to the wiki's _config.yml under wikidown: (run wikidown pages first if the wiki has no _config.yml):

wikidown:
  web_components:
    modules:
      - /assets/components/wikidown-gallery.js
    styles:
      - /assets/components/wikidown-gallery.css
    tags:
      - wikidown-gallery

You don't need to copy any files: both come with the starter theme.

Each photo is a <figure>: a link to the full-size image around a thumbnail, and an optional caption. With one size of each photo, use the same file for both.

<wikidown-gallery label="Photos from the opening" columns="2">
  <figure>
    <a href="../.attachments/opening/rabbits.jpg" data-width="1000" data-height="894">
      <img src="../.attachments/opening/rabbits.jpg" alt="Two copper rabbit sculptures" width="1000" height="894" loading="lazy">
    </a>
    <figcaption>Copper rabbits by Jud Turner</figcaption>
  </figure>
  <figure>
    <a href="../.attachments/opening/highland-cow.jpg" data-width="1000" data-height="750">
      <img src="../.attachments/opening/highland-cow.jpg" alt="A shaggy Highland cow sculpture" width="1000" height="750" loading="lazy">
    </a>
  </figure>
</wikidown-gallery>

Write the page with the CLI as usual (wikidown edit or write-section), or ask your agent: "Turn the photos on the Oblivion Gallery page into a wikidown-gallery." The agent skill knows the markup.

3. Check and preview

wikidown check-links
wikidown export-html --output _site --clean

check-links checks every href and src in the gallery. Preview the site through a local web server, such as npx serve _site or dotnet serve -d _site. Opening the .html file straight from disk doesn't run the gallery's script.

What readers get

Tips

Want swipe and zoom?

Point the config at another implementation. Web Components shows how to load Web Awesome's <wa-lightbox> from a CDN, which adds swipe, pinch zoom and a thumbnail strip, and how to load any other component library.