Skip to content

Set post thumbnail image file from page bundles #6

@solrayc

Description

@solrayc

We manage our content structure with hugo page bundle functionality.

It is a convenient way to organize article assets.
It also allows us to make use of image processing build in hugo. We use image processing in hugo to automatically resize and compress images.

We got image processing working with a schortcode from this article.

It appears that setting image = "main_image.jpg" in article front matter only works with image files stored in static/images/ folder.
Front matter does not recognize images that are bundled with the article, like this:

├── posts
│   ├── my-post
│   │   ├── main_image1.jpg
│   │   └── index.md
│   └── my-other-post
│        ├── images
│        │   └── main_image2.jpg
│        └── index.md

Is there a way to get post thumbnail and main image working with files from page bundle?
Perhaps we need to update layouts/index.html and layouts/_default/single.html` to make it work.

I am very new to Go and Hugo template, so I need your help.
Not sure, but perhaps the issues are somewhere here:

{{ $bg := (absURL (printf "images/%s" $image)) }}

<img src = '{{ absURL (printf "images/%s" .) }}' alt = '{{ . }}' class = 'post_thumbnail'>

Would appreciate your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions