question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Post image from Hugo page resources

See original GitHub issue

I am using Frontmatter in connection with Hugo and wonder if it’s possible to somehow use images as article image on the dashboard when they are defined in the resources section of the frontmatter.

frontmatter sample

---
...
resources:
  - title: "caption"
    id: "id1"
    src: "header.jpg"
  - title: "caption2"
    id: "id2"
    src: "header2.jpg"
---

I would expect the solution to show the image of the first resource (header.jpg). This can of course be “hacked” by adding an additional frontmatter item with the header image, but that would not be used in the theme at all and only for Frontmatter to look nice.

Page Resources is a fairly integral piece of Hugos page bundle system. This would have to check if the first item is an actual image though, because other media types could take that place.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
estruyfcommented, Mar 28, 2022

New beta version is available with this enhancement.

1reaction
estruyfcommented, Mar 28, 2022

The preview image for block fields is not yet supported, but I’ll push a new update in a couple of minutes to have this supported as well.

In your case, what you have to do is update the resources field group as follows:

{
  "id": "resources",
  "labelField": "src",
  "fields": [
    {
      "title": "Path/Filename",
      "name": "src",
      "type": "image",
      "isPreviewImage": true
    },
    {
      "title": "Title",
      "name": "title",
      "type": "string",
      "single": true
    },
    {
      "title": "Name (Identifier)",
      "name": "name",
      "type": "string",
      "single": true
    }
  ]
}

Changed the src field to type image and set it as the preview image.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Page Resources - Hugo
In this example, first-post is a page bundle with access to 10 page resources including audio, data, documents, images, and video.
Read more >
Guide for different ways to access your image resources
In this tutorial I will focus on different ways to handle images in Hugo. Learn how to find and select images in every...
Read more >
Hugo Page Resources - Regis Philibert
In this article we'll cover Page Resources and its impact on the way we structure our content folders, what methods and properties it...
Read more >
How to insert an image in my post on Hugo? - Stack Overflow
Option 1. Put all of your images in the static/ directory. · Option 2. Use sub-directories to hold the markdown file and any...
Read more >
Image render hook does not work with page resources any more
0 on MacOS Catalina Yes, this error occurs with latest Hugo version. Before 0.64 this was possible: {{ $image ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found