<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Hugo on Bitlager Blog</title>
    <link>https://blog.bitlager.de/series/hugo/</link>
    <description>Recent content in Hugo on Bitlager Blog</description>
    <generator>Hugo -- 0.145.0</generator>
    <language>en</language>
    <lastBuildDate>Thu, 01 Jan 1970 00:30:00 +0100</lastBuildDate>
    <atom:link href="https://blog.bitlager.de/series/hugo/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Examples for Hugo Gallery Shortcode</title>
      <link>https://blog.bitlager.de/posts/tech/hugo-gallery-shortcode-example/</link>
      <pubDate>Thu, 01 Jan 1970 00:30:00 +0100</pubDate>
      <guid>https://blog.bitlager.de/posts/tech/hugo-gallery-shortcode-example/</guid>
      <description>&lt;h2 id=&#34;gallery-with-3-images&#34;&gt;Gallery with 3 images&lt;/h2&gt;
&lt;h3 id=&#34;first-gallery&#34;&gt;First gallery&lt;/h3&gt;
&lt;style&gt;
    .image-gallery {
        overflow: auto;
        margin-left: -1% !important;
    }

    .image-gallery li {
        float: left;
        display: block;
        margin: 0 0 1% 1%;
    }

    .image-gallery[data-count=&#34;2&#34;] li {
        width: 49%;
    }

    .image-gallery[data-count=&#34;3&#34;] li {
        width: 32%;
    }

    .image-gallery[data-count=&#34;4&#34;] li {
        width: 24%;
    }

    .image-gallery[data-count=&#34;5&#34;] li {
        width: 19%;
    }

    .post-content .image-gallery a {
        box-shadow: none;
        box-decoration-break: none;
        -webkit-box-decoration-break: none;
    }

    .image-gallery li a {
        text-align: center;
        text-decoration: none;
        color: #777;
        display: block;
    }

    .image-gallery li a span {
        display: block;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        padding: 3px 0;
    }

    .image-gallery li a img {
        width: 100%;
        aspect-ratio: 1 / 1;
        display: block;
        border-radius: 8px;
        object-fit: cover;
        background: #f5f5f5;
        transition: transform 0.3s ease;
    }

    .image-gallery li a:hover img {
        transform: scale(1.01);
    }

    .simple-lightbox {
        display: none;
        position: fixed;
        z-index: 999;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.9);
    }

    .simple-lightbox.active {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .lightbox-content {
        position: relative;
        max-width: 90%;
        max-height: 90vh;
    }

    .lightbox-content img {
        max-width: 100%;
        max-height: 90vh;
        object-fit: contain;
    }

    .lightbox-caption {
        position: absolute;
        bottom: -60px;
        left: 0;
        right: 0;
        color: white;
        text-align: center;
        padding: 10px;
    }

    .lightbox-close {
        position: absolute;
        top: 20px;
        right: 20px;
        color: white;
        font-size: 30px;
        cursor: pointer;
        width: 30px;
        height: 30px;
        line-height: 30px;
        text-align: center;
    }

    .lightbox-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        color: white;
        font-size: 30px;
        cursor: pointer;
        padding: 20px;
        user-select: none;
    }

    .lightbox-prev {
        left: 20px;
    }

    .lightbox-next {
        right: 20px;
    }
&lt;/style&gt;



&lt;div class=&#34;simple-lightbox&#34; id=&#34;simple-lightbox-gallery-49a5b11077ae441f9a5c85c7d0f031859528bcff&#34;&gt;
    &lt;div class=&#34;lightbox-content&#34;&gt;
        &lt;img src=&#34;&#34; alt=&#34;&#34;&gt;
        &lt;div class=&#34;lightbox-caption&#34;&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&#34;lightbox-close&#34;&gt;&amp;times;&lt;/div&gt;
    &lt;div class=&#34;lightbox-nav lightbox-prev&#34;&gt;&amp;lt;&lt;/div&gt;
    &lt;div class=&#34;lightbox-nav lightbox-next&#34;&gt;&amp;gt;&lt;/div&gt;
&lt;/div&gt;

&lt;ul class=&#34;image-gallery&#34; id=&#34;image-gallery-gallery-49a5b11077ae441f9a5c85c7d0f031859528bcff&#34;&gt;
    
    
    
    
    
    
    
    
    
    

    
    &lt;li&gt;
        &lt;a href=&#34;https://blog.bitlager.de/images/example/1%20Custom%20Caption.jpeg&#34; title=&#34;1 Custom Caption&#34; class=&#34;gallery-image&#34;
            data-caption=&#34;1 Custom Caption&#34;&gt;
            &lt;img src=&#34;https://blog.bitlager.de/images/example/1%20Custom%20Caption.jpeg&#34; alt=&#34;1 Custom Caption&#34; title=&#34;1 Custom Caption&#34;&gt;
            &lt;span&gt;1 Custom Caption&lt;/span&gt;
        &lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a href=&#34;https://blog.bitlager.de/images/example/2-This-is-a-caption.jpeg&#34; title=&#34;2-This-is-a-caption&#34; class=&#34;gallery-image&#34;
            data-caption=&#34;2-This-is-a-caption&#34;&gt;
            &lt;img src=&#34;https://blog.bitlager.de/images/example/2-This-is-a-caption.jpeg&#34; alt=&#34;2-This-is-a-caption&#34; title=&#34;2-This-is-a-caption&#34;&gt;
            &lt;span&gt;2-This-is-a-caption&lt;/span&gt;
        &lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a href=&#34;https://blog.bitlager.de/images/example/3%20Naming%20defines%20order.jpeg&#34; title=&#34;3 Naming defines order&#34; class=&#34;gallery-image&#34;
            data-caption=&#34;3 Naming defines order&#34;&gt;
            &lt;img src=&#34;https://blog.bitlager.de/images/example/3%20Naming%20defines%20order.jpeg&#34; alt=&#34;3 Naming defines order&#34; title=&#34;3 Naming defines order&#34;&gt;
            &lt;span&gt;3 Naming defines order&lt;/span&gt;
        &lt;/a&gt;
    &lt;/li&gt;
    
    
&lt;/ul&gt;

&lt;script&gt;
    document.addEventListener(&#39;DOMContentLoaded&#39;, function () {
        const lightbox = document.querySelector(&#39;#simple-lightbox-gallery-49a5b11077ae441f9a5c85c7d0f031859528bcff&#39;);
        const lightboxImg = lightbox.querySelector(&#39;img&#39;);
        const lightboxCaption = lightbox.querySelector(&#39;.lightbox-caption&#39;);
        const gallery = document.querySelector(&#39;#image-gallery-gallery-49a5b11077ae441f9a5c85c7d0f031859528bcff&#39;);
        let currentIndex = 0;
        let images = [];

        
        const imageCount = gallery.querySelectorAll(&#39;.gallery-image&#39;).length;
        gallery.setAttribute(&#39;data-count&#39;, imageCount.toString());

        
        gallery.querySelectorAll(&#39;.gallery-image&#39;).forEach((link, index) =&gt; {
            images.push({
                src: link.href,
                title: link.getAttribute(&#39;data-caption&#39;)
            });

            link.addEventListener(&#39;click&#39;, (e) =&gt; {
                e.preventDefault();
                currentIndex = index;
                showImage(currentIndex);
            });
        });

        function showImage(index) {
            lightboxImg.src = images[index].src;
            lightboxCaption.textContent = images[index].title;
            lightbox.classList.add(&#39;active&#39;);
        }

        lightbox.querySelector(&#39;.lightbox-close&#39;).addEventListener(&#39;click&#39;, () =&gt; {
            lightbox.classList.remove(&#39;active&#39;);
        });

        lightbox.querySelector(&#39;.lightbox-prev&#39;).addEventListener(&#39;click&#39;, () =&gt; {
            currentIndex = (currentIndex - 1 + images.length) % images.length;
            showImage(currentIndex);
        });

        lightbox.querySelector(&#39;.lightbox-next&#39;).addEventListener(&#39;click&#39;, () =&gt; {
            currentIndex = (currentIndex + 1) % images.length;
            showImage(currentIndex);
        });

        document.addEventListener(&#39;keydown&#39;, (e) =&gt; {
            if (!lightbox.classList.contains(&#39;active&#39;)) return;

            if (e.key === &#39;Escape&#39;) {
                lightbox.classList.remove(&#39;active&#39;);
            } else if (e.key === &#39;ArrowLeft&#39;) {
                currentIndex = (currentIndex - 1 + images.length) % images.length;
                showImage(currentIndex);
            } else if (e.key === &#39;ArrowRight&#39;) {
                currentIndex = (currentIndex + 1) % images.length;
                showImage(currentIndex);
            }
        });

        lightbox.addEventListener(&#39;click&#39;, (e) =&gt; {
            if (e.target === lightbox) {
                lightbox.classList.remove(&#39;active&#39;);
            }
        });
    });
&lt;/script&gt;
&lt;h3 id=&#34;second-gallery&#34;&gt;Second gallery&lt;/h3&gt;
&lt;style&gt;
    .image-gallery {
        overflow: auto;
        margin-left: -1% !important;
    }

    .image-gallery li {
        float: left;
        display: block;
        margin: 0 0 1% 1%;
    }

    .image-gallery[data-count=&#34;2&#34;] li {
        width: 49%;
    }

    .image-gallery[data-count=&#34;3&#34;] li {
        width: 32%;
    }

    .image-gallery[data-count=&#34;4&#34;] li {
        width: 24%;
    }

    .image-gallery[data-count=&#34;5&#34;] li {
        width: 19%;
    }

    .post-content .image-gallery a {
        box-shadow: none;
        box-decoration-break: none;
        -webkit-box-decoration-break: none;
    }

    .image-gallery li a {
        text-align: center;
        text-decoration: none;
        color: #777;
        display: block;
    }

    .image-gallery li a span {
        display: block;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        padding: 3px 0;
    }

    .image-gallery li a img {
        width: 100%;
        aspect-ratio: 1 / 1;
        display: block;
        border-radius: 8px;
        object-fit: cover;
        background: #f5f5f5;
        transition: transform 0.3s ease;
    }

    .image-gallery li a:hover img {
        transform: scale(1.01);
    }

    .simple-lightbox {
        display: none;
        position: fixed;
        z-index: 999;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.9);
    }

    .simple-lightbox.active {
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .lightbox-content {
        position: relative;
        max-width: 90%;
        max-height: 90vh;
    }

    .lightbox-content img {
        max-width: 100%;
        max-height: 90vh;
        object-fit: contain;
    }

    .lightbox-caption {
        position: absolute;
        bottom: -60px;
        left: 0;
        right: 0;
        color: white;
        text-align: center;
        padding: 10px;
    }

    .lightbox-close {
        position: absolute;
        top: 20px;
        right: 20px;
        color: white;
        font-size: 30px;
        cursor: pointer;
        width: 30px;
        height: 30px;
        line-height: 30px;
        text-align: center;
    }

    .lightbox-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        color: white;
        font-size: 30px;
        cursor: pointer;
        padding: 20px;
        user-select: none;
    }

    .lightbox-prev {
        left: 20px;
    }

    .lightbox-next {
        right: 20px;
    }
&lt;/style&gt;



&lt;div class=&#34;simple-lightbox&#34; id=&#34;simple-lightbox-gallery-6d118b487789e2bffdd0b20fcbeb866da062010a&#34;&gt;
    &lt;div class=&#34;lightbox-content&#34;&gt;
        &lt;img src=&#34;&#34; alt=&#34;&#34;&gt;
        &lt;div class=&#34;lightbox-caption&#34;&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&#34;lightbox-close&#34;&gt;&amp;times;&lt;/div&gt;
    &lt;div class=&#34;lightbox-nav lightbox-prev&#34;&gt;&amp;lt;&lt;/div&gt;
    &lt;div class=&#34;lightbox-nav lightbox-next&#34;&gt;&amp;gt;&lt;/div&gt;
&lt;/div&gt;

&lt;ul class=&#34;image-gallery&#34; id=&#34;image-gallery-gallery-6d118b487789e2bffdd0b20fcbeb866da062010a&#34;&gt;
    
    
    
    
    
    
    
    
    
    

    
    &lt;li&gt;
        &lt;a href=&#34;https://blog.bitlager.de/images/example2/1%20Custom%20Caption.jpeg&#34; title=&#34;1 Custom Caption&#34; class=&#34;gallery-image&#34;
            data-caption=&#34;1 Custom Caption&#34;&gt;
            &lt;img src=&#34;https://blog.bitlager.de/images/example2/1%20Custom%20Caption.jpeg&#34; alt=&#34;1 Custom Caption&#34; title=&#34;1 Custom Caption&#34;&gt;
            &lt;span&gt;1 Custom Caption&lt;/span&gt;
        &lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a href=&#34;https://blog.bitlager.de/images/example2/2-This-is-a-caption.jpeg&#34; title=&#34;2-This-is-a-caption&#34; class=&#34;gallery-image&#34;
            data-caption=&#34;2-This-is-a-caption&#34;&gt;
            &lt;img src=&#34;https://blog.bitlager.de/images/example2/2-This-is-a-caption.jpeg&#34; alt=&#34;2-This-is-a-caption&#34; title=&#34;2-This-is-a-caption&#34;&gt;
            &lt;span&gt;2-This-is-a-caption&lt;/span&gt;
        &lt;/a&gt;
    &lt;/li&gt;
    &lt;li&gt;
        &lt;a href=&#34;https://blog.bitlager.de/images/example2/3%20Naming%20defines%20order.jpeg&#34; title=&#34;3 Naming defines order&#34; class=&#34;gallery-image&#34;
            data-caption=&#34;3 Naming defines order&#34;&gt;
            &lt;img src=&#34;https://blog.bitlager.de/images/example2/3%20Naming%20defines%20order.jpeg&#34; alt=&#34;3 Naming defines order&#34; title=&#34;3 Naming defines order&#34;&gt;
            &lt;span&gt;3 Naming defines order&lt;/span&gt;
        &lt;/a&gt;
    &lt;/li&gt;
    
    
&lt;/ul&gt;

&lt;script&gt;
    document.addEventListener(&#39;DOMContentLoaded&#39;, function () {
        const lightbox = document.querySelector(&#39;#simple-lightbox-gallery-6d118b487789e2bffdd0b20fcbeb866da062010a&#39;);
        const lightboxImg = lightbox.querySelector(&#39;img&#39;);
        const lightboxCaption = lightbox.querySelector(&#39;.lightbox-caption&#39;);
        const gallery = document.querySelector(&#39;#image-gallery-gallery-6d118b487789e2bffdd0b20fcbeb866da062010a&#39;);
        let currentIndex = 0;
        let images = [];

        
        const imageCount = gallery.querySelectorAll(&#39;.gallery-image&#39;).length;
        gallery.setAttribute(&#39;data-count&#39;, imageCount.toString());

        
        gallery.querySelectorAll(&#39;.gallery-image&#39;).forEach((link, index) =&gt; {
            images.push({
                src: link.href,
                title: link.getAttribute(&#39;data-caption&#39;)
            });

            link.addEventListener(&#39;click&#39;, (e) =&gt; {
                e.preventDefault();
                currentIndex = index;
                showImage(currentIndex);
            });
        });

        function showImage(index) {
            lightboxImg.src = images[index].src;
            lightboxCaption.textContent = images[index].title;
            lightbox.classList.add(&#39;active&#39;);
        }

        lightbox.querySelector(&#39;.lightbox-close&#39;).addEventListener(&#39;click&#39;, () =&gt; {
            lightbox.classList.remove(&#39;active&#39;);
        });

        lightbox.querySelector(&#39;.lightbox-prev&#39;).addEventListener(&#39;click&#39;, () =&gt; {
            currentIndex = (currentIndex - 1 + images.length) % images.length;
            showImage(currentIndex);
        });

        lightbox.querySelector(&#39;.lightbox-next&#39;).addEventListener(&#39;click&#39;, () =&gt; {
            currentIndex = (currentIndex + 1) % images.length;
            showImage(currentIndex);
        });

        document.addEventListener(&#39;keydown&#39;, (e) =&gt; {
            if (!lightbox.classList.contains(&#39;active&#39;)) return;

            if (e.key === &#39;Escape&#39;) {
                lightbox.classList.remove(&#39;active&#39;);
            } else if (e.key === &#39;ArrowLeft&#39;) {
                currentIndex = (currentIndex - 1 + images.length) % images.length;
                showImage(currentIndex);
            } else if (e.key === &#39;ArrowRight&#39;) {
                currentIndex = (currentIndex + 1) % images.length;
                showImage(currentIndex);
            }
        });

        lightbox.addEventListener(&#39;click&#39;, (e) =&gt; {
            if (e.target === lightbox) {
                lightbox.classList.remove(&#39;active&#39;);
            }
        });
    });
&lt;/script&gt;
&lt;h3 id=&#34;stacked-gallery&#34;&gt;Stacked gallery&lt;/h3&gt;
&lt;style&gt;
    .stacked-image-gallery {
        position: relative;
        max-width: 400px;
        min-height: 400px;
        margin: 0 auto;
        padding: 20px 0 420px 0;
    }.stacked-image-gallery li {
    list-style: none;
    position: absolute;
    width: 80%;
    max-width: 300px;
    transition: transform 0.3s ease, z-index 0.3s ease;
}

.stacked-image-gallery li:nth-child(1) {
    transform: rotate(2deg) translate(0, 0);
    z-index: 1;
}

.stacked-image-gallery li:nth-child(2) {
    transform: rotate(-3deg) translate(10px, 5px);
    z-index: 2;
}

.stacked-image-gallery li:nth-child(3) {
    transform: rotate(4deg) translate(-10px, 10px);
    z-index: 3;
}

.stacked-image-gallery li:nth-child(4) {
    transform: rotate(-2deg) translate(15px, -5px);
    z-index: 4;
}

.stacked-image-gallery li:nth-child(5) {
    transform: rotate(5deg) translate(-5px, 15px);
    z-index: 5;
}

.stacked-image-gallery li:hover {
    transform: scale(1.1) translateY(-20px);
    z-index: 10;
}

.stacked-image-gallery li a {
    display: block;
    text-decoration: none;
    color: #777;
    background: #fff;
    padding: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.stacked-image-gallery li a img {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: block;
    border-radius: 4px;
    object-fit: cover;
    background: #f5f5f5;
}

.stacked-image-gallery li a span {
    display: block;
    text-align: center;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    padding: 5px 0;
    font-size: 14px;
}

.simple-lightbox {
    display: none;
    position: fixed;
    z-index: 999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
}

.simple-lightbox.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.lightbox-caption {
    position: absolute;
    bottom: -60px;
    left: 0;
    right: 0;
    color: white;
    text-align: center;
    padding: 10px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 30px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 30px;
    cursor: pointer;
    padding: 20px;
    user-select: none;
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}&lt;/style&gt;
&lt;div class=&#34;simple-lightbox&#34; id=&#34;simple-lightbox-stacked-gallery-49a5b11077ae441f9a5c85c7d0f031859528bcff&#34;&gt;
    &lt;div class=&#34;lightbox-content&#34;&gt;
        &lt;img src=&#34;&#34; alt=&#34;&#34;&gt;
        &lt;div class=&#34;lightbox-caption&#34;&gt;&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class=&#34;lightbox-close&#34;&gt;&amp;times;&lt;/div&gt;
    &lt;div class=&#34;lightbox-nav lightbox-prev&#34;&gt;&amp;lt;&lt;/div&gt;
    &lt;div class=&#34;lightbox-nav lightbox-next&#34;&gt;&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;ul class=&#34;stacked-image-gallery&#34; id=&#34;stacked-image-gallery-stacked-gallery-49a5b11077ae441f9a5c85c7d0f031859528bcff&#34;&gt;
    
    
    
    
    
    
    
    
    
    

&lt;li&gt;
    &lt;a href=&#34;https://blog.bitlager.de/images/example/1%20Custom%20Caption.jpeg&#34; title=&#34;1 Custom Caption&#34; class=&#34;gallery-image&#34;
        data-caption=&#34;1 Custom Caption&#34;&gt;
        &lt;img src=&#34;https://blog.bitlager.de/images/example/1%20Custom%20Caption.jpeg&#34; alt=&#34;1 Custom Caption&#34; title=&#34;1 Custom Caption&#34;&gt;
        &lt;span&gt;1 Custom Caption&lt;/span&gt;
    &lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;https://blog.bitlager.de/images/example/2-This-is-a-caption.jpeg&#34; title=&#34;2-This-is-a-caption&#34; class=&#34;gallery-image&#34;
        data-caption=&#34;2-This-is-a-caption&#34;&gt;
        &lt;img src=&#34;https://blog.bitlager.de/images/example/2-This-is-a-caption.jpeg&#34; alt=&#34;2-This-is-a-caption&#34; title=&#34;2-This-is-a-caption&#34;&gt;
        &lt;span&gt;2-This-is-a-caption&lt;/span&gt;
    &lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
    &lt;a href=&#34;https://blog.bitlager.de/images/example/3%20Naming%20defines%20order.jpeg&#34; title=&#34;3 Naming defines order&#34; class=&#34;gallery-image&#34;
        data-caption=&#34;3 Naming defines order&#34;&gt;
        &lt;img src=&#34;https://blog.bitlager.de/images/example/3%20Naming%20defines%20order.jpeg&#34; alt=&#34;3 Naming defines order&#34; title=&#34;3 Naming defines order&#34;&gt;
        &lt;span&gt;3 Naming defines order&lt;/span&gt;
    &lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;script&gt;
    document.addEventListener(&#39;DOMContentLoaded&#39;, function () {
        const lightbox = document.querySelector(&#39;#simple-lightbox-stacked-gallery-49a5b11077ae441f9a5c85c7d0f031859528bcff&#39;);
        const lightboxImg = lightbox.querySelector(&#39;img&#39;);
        const lightboxCaption = lightbox.querySelector(&#39;.lightbox-caption&#39;);
        const gallery = document.querySelector(&#39;#stacked-image-gallery-stacked-gallery-49a5b11077ae441f9a5c85c7d0f031859528bcff&#39;);
        let currentIndex = 0;
        let images = [];

        
        gallery.querySelectorAll(&#39;.gallery-image&#39;).forEach((link, index) =&gt; {
            images.push({
                src: link.href,
                title: link.getAttribute(&#39;data-caption&#39;)
            });

            link.addEventListener(&#39;click&#39;, (e) =&gt; {
                e.preventDefault();
                currentIndex = index;
                showImage(currentIndex);
            });
        });

        function showImage(index) {
            lightboxImg.src = images[index].src;
            lightboxCaption.textContent = images[index].title;
            lightbox.classList.add(&#39;active&#39;);
        }

        lightbox.querySelector(&#39;.lightbox-close&#39;).addEventListener(&#39;click&#39;, () =&gt; {
            lightbox.classList.remove(&#39;active&#39;);
        });

        lightbox.querySelector(&#39;.lightbox-prev&#39;).addEventListener(&#39;click&#39;, () =&gt; {
            currentIndex = (currentIndex - 1 + images.length) % images.length;
            showImage(currentIndex);
        });

        lightbox.querySelector(&#39;.lightbox-next&#39;).addEventListener(&#39;click&#39;, () =&gt; {
            currentIndex = (currentIndex + 1) % images.length;
            showImage(currentIndex);
        });

        document.addEventListener(&#39;keydown&#39;, (e) =&gt; {
            if (!lightbox.classList.contains(&#39;active&#39;)) return;

            if (e.key === &#39;Escape&#39;) {
                lightbox.classList.remove(&#39;active&#39;);
            } else if (e.key === &#39;ArrowLeft&#39;) {
                currentIndex = (currentIndex - 1 + images.length) % images.length;
                showImage(currentIndex);
            } else if (e.key === &#39;ArrowRight&#39;) {
                currentIndex = (currentIndex + 1) % images.length;
                showImage(currentIndex);
            }
        });

        lightbox.addEventListener(&#39;click&#39;, (e) =&gt; {
            if (e.target === lightbox) {
                lightbox.classList.remove(&#39;active&#39;);
            }
        });
    });
&lt;/script&gt;
&lt;p&gt;&lt;strong&gt;SOURCE&lt;/strong&gt;: &lt;a href=&#34;https://github.com/thisdev/hugo-gallery-shortcode&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Github&lt;/a&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
