Skip to content
MkDocs mkdocs-glightbox & mkdocs-image-gallery-plugin

MkDocs mkdocs-glightbox & mkdocs-image-gallery-plugin

Install & setup

The mkdocs-glightbox plugin

Here is a minimal, working setup for mkdocs-glightbox with Material for MkDocs, plus a few useful configuration examples.

1. Install the plugin

In your environment (or Docker image), install the plugin:

pip install mkdocs-glightbox

This works with standard MkDocs and Material; in Docker you may need to extend the official image and add mkdocs-glightbox in a custom Dockerfile.

2. Enable in mkdocs.yml

Add glightbox to the plugins section:

plugins:
  - glightbox

By default, all Markdown images become clickable and open in a lightbox, except:

  • Images already wrapped in <a> links.

  • Emoji images injected by pymdown-extensions.

You do not need to change your Markdown syntax; standard ![Alt text](path/to/img.png) works.
​``` 

#### 3. Recommended options for Material

You can tune behavior via options in mkdocs.yml. A common setup with Material is:

```yaml
plugins:
  - glightbox:
      touchNavigation: true      # Swipe on mobile
      loop: false                # Do not loop from last back to first
      effect: zoom               # Open effect: zoom | fade | none
      slide_effect: slide        # Slide effect: slide | zoom | fade | none
      zoomable: true             # Allow zooming the image
      draggable: true            # Drag with mouse to change image
      auto_themed: true          # Match Material light/dark mode
      auto_caption: true         # Use image alt text as caption
      caption_position: bottom   # bottom | top | left | right

These map directly to GLightbox features (zoom, prev/next, captions) while integrating with Material’s dark/light theme.

4. Per-image or per-page control (optional)

If you want to enable the lightbox only for specific images or pages:

Set manual: true globally:

plugins:
  - glightbox:
      manual: true

Then either:

Add class on-glb to individual images with attr_list, e.g.:

{ .on-glb }

Or enable it per page using front-matter:

---
glightbox:
  auto_themed: true
---

!!! note “You can also exclude certain images globally with skip_classes, e.g. { .skip-lightbox }.

Propably the best solution in our case(lgn).

”

5. Per-Document overrides

mkdocs-glightbox supports per-document overrides via front-matter even with global activation, plus per-image control via classes. These use Material’s meta and attr_list extensions.

Per-document disable (front-matter) Keep manual: false globally (default, lightbox on), but disable all images on a specific page:

---
glightbox: false
---

This overrides the global setting for that document only—lightbox off for all images there.

Per-document manual mode (mixed control) To mix enabled/disabled images on one page:

---
glightbox-manual: true
---

Now only images with { .on-glb } get lightbox; others don’t. Great for pages with both diagrams (no lightbox) and photos (lightbox). ​

Per-image disable (with global on) No front-matter needed—add class to skip specific images anywhere:

![No lightbox](image.jpg){ .off-glb }

Or custom class:

![No lightbox](image.jpg){ .no-lightbox }

Configure custom classes in mkdocs.yml:

plugins:
  - glightbox:
      skip_classes:
        - no-lightbox
        - diagram

Required extensions

Ensure these are in mkdocs.yml (standard with Material):

markdown_extensions (if not using material):

  • meta # Front-matter support
  • attr_list # { .class } syntax

Summary of combinations

GoalGlobalFront-matterImage class
Disable entire pagemanual: falseglightbox: falseN/A
Opt-in images onlymanual: trueglightbox-manual: true{ .on-glb }
Skip few imagesmanual: falseNone{ .off-glb }

This gives full granular control without changing global behavior

6. How it behaves (if not using any for document or image overrides. See )

Once configured:

  • Clicking a supported image opens it in a GLightbox overlay.

  • Users can go to previous/next images via arrows, mouse drag, or swipe.

  • Zoom and captions work according to your options.


The mkdocs-image-gallery-plugin

If you have folders with many images and want a proper gallery view, you can add mkdocs-image-gallery-plugin on top of glightbox.

It’s straightforward to set up and requires the glightbox plugin for lightbox interactions like zoom and prev/next.

  • Auto-builds a gallery page from a folder of images.

  • Provides shortcodes like {{gallery_preview}} and {{gallery_html}} to drop a gallery into any page.

  • Uses glightbox when images are clicked, so users still get zoom and previous/next controls.

1. Installation

Install via pip:

pip install mkdocs-image-gallery-plugin.

It requires Python 3.8+ and pairs with mkdocs-glightbox for full functionality: pip install mkdocs-glightbox.

2. mkdocs.yml Configuration

Add the plugin to your mkdocs.yml under plugins and specify the image folder path (relative to your docs/ directory).

plugins:
  - glightbox  # Required for lightbox on click
  - image-gallery:
      image_folder: "./assets/images/gallery"  # Path to folder with images; subfolders become categories

NOPE. No nav in yml Add a page with the gallery to your nav for easy access:

    text
    nav:
    - Gallery: gallery.md

Run mkdocs serve to test; it supports both dev server and static builds.

3. Usage Examples

  • Create a folder like docs/assets/images/gallery/ and add your images (supports subfolders for categories).

  • In any Markdown page (e.g., docs/gallery.md), insert shortcodes:

  • Preview grid: {{gallery_preview}} – Shows thumbnails linking to full gallery.

  • Full gallery: {{gallery_html}} – Renders complete responsive grid of all images.

  • Images click to glightbox for zoom, prev/next navigation, and captions.

That’s it—no further customization yet, but more options are planned.


!!! note “Extended info below.”

What benefits in addition to glightbox will MkDocs image gallery bring??

mkdocs-image-gallery-plugin adds automatic grid layouts and folder organization that glightbox alone can’t provide. ​ Key benefits beyond glightbox:

  1. Auto-generates gallery pages

    Drop images in docs/assets/images/gallery/ (with subfolders)

    Plugin auto-creates responsive grid thumbnails

    No manual HTML/CSS needed for gallery layouts

  2. Two shortcodes for flexible embedding

{{gallery_preview}}  → Small thumbnail grid linking to full gallery
{{gallery_html}}     → Full responsive image grid on any page
  1. Subfolder organization
docs/assets/images/gallery/
├── screenshots/     → Becomes "Screenshots" category
├── diagrams/        → Becomes "Diagrams" category
└── photos/

Plugin auto-creates category tabs/grids automatically.

  1. Works with glightbox
  • Gallery thumbnails click → glightbox opens (zoom/prev/next)

  • Same lightbox controls you’re already using

Perfect use case

Instead of 20 scattered ![ ](img.jpg) Markdown images, you get:
# Image Gallery
{{gallery_html}}

→ Instant professional photo grid from your folder.

Bottom line: Glightbox = click-to-zoom. Image-gallery = organized photo browser. Together = complete image solution for docs with lots of visuals.


Built‑in image helpers in Material

Material itself adds helpers for:

  • Alignment and captions (via attr_list and its image config).

  • Lazy loading and some styling improvements.

These improve layout and performance, but for interactive zoom/prev/next you still want a lightbox plugin like mkdocs-glightbox.

So, what benefits besides glightbox will image gallery bring?? mkdocs-image-gallery-plugin adds automatic grid layouts and folder organization that glightbox alone can’t provide. ​

Bottom line: Glightbox = click-to-zoom. Image-gallery = organized photo browser. Together = complete image solution for docs with lots of visuals.