monkeyWzr / hugo-theme-cactus

Cactus theme for hugo
MIT License
537 stars 338 forks source link

Images are shown duplicated both at the start of the post and inline #142

Closed sespinoza-dev closed 1 month ago

sespinoza-dev commented 1 month ago

Summary

When adding images to your post, you'll see it duplicated both inline (where you want it) and at the start of the post.

How to reproduce

  1. Create a new post hugo new posts/test-article/index.md and fill in the content:
    
    +++
    title = 'Test Article'
    date = 2024-08-16T14:38:45+03:00
    draft = false
    +++

This is a test text

This is an image

my img



2. Add an image in `content/posts/test-article/cat.jpg`
3. Start the server `hugo server`
4. Open http://localhost:1313/posts/test-article/
5. Observe the page

You will see that two images are showed
![image](https://github.com/user-attachments/assets/63571099-da23-4826-b5e4-3331faac3a8c)

### Expected result

Only the inline image should be shown.
sespinoza-dev commented 1 month ago

I fix it by creating a new file in layouts/posts/single.html copying the content in themes/cactus/layouts/posts/single.html and removing the lines:

  {{ with .Resources.ByType "image" }}
    <div class="article-gallery">
      {{ range $index, $value := . }}
      <a class="gallery-item" href="{{ .RelPermalink }}" rel="gallery_{{ $index }}">
          <img src="{{ .RelPermalink }}" itemprop="image" />
      </a>
      {{ end }}
    </div>
  {{ end }}