Skip to content

feat: support page bundle images in OpenGraph metadata#892

Merged
imfing merged 3 commits intoimfing:mainfrom
torbjornbp:main
Jan 4, 2026
Merged

feat: support page bundle images in OpenGraph metadata#892
imfing merged 3 commits intoimfing:mainfrom
torbjornbp:main

Conversation

@torbjornbp
Copy link
Contributor

I'm unsure if this is a good idea, but I've made some changes to the opengraph.html layouyt so that it can use page bundle images for individual pages.

It keeps the image structure a bit less confusing if you are using page bundles resources for images on individual pages.

It's vibe coded, but seems to function as expected on my page.

@netlify
Copy link

netlify bot commented Dec 11, 2025

Deploy Preview for hugo-hextra ready!

Name Link
🔨 Latest commit cb81180
🔍 Latest deploy log https://app.netlify.com/projects/hugo-hextra/deploys/695aa23146c1ad00081cbf33
😎 Deploy Preview https://deploy-preview-892--hugo-hextra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the file to non-executable:

chmod 644 layouts/_partials/opengraph.html

@torbjornbp
Copy link
Contributor Author

Should be fixed

Copy link
Owner

@imfing imfing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This is a useful enhancement that adds support for page bundle images in OpenGraph metadata. The implementation is clean and maintains backward compatibility.

Strengths

✅ Enables using images from page bundles (Hugo's recommended pattern for organizing content)
✅ Maintains backward compatibility with existing absolute/site-level paths
✅ Removes dead code ($featured variable that was always empty)
✅ Improves code formatting and consistency

Suggestions for Improvement

1. Add Documentation
Please update docs/content/docs/guide/configuration.md to document this new capability. Example:

```yaml

In a page bundle (content/mypage/index.md with myimage.jpg in same directory)

params:
images:
- "myimage.jpg" # Will use page bundle resource if it exists
- "/images/fallback.jpg" # Falls back to site-level image
```

2. Create Example/Test Page
Consider adding a test page bundle in the docs to demonstrate this feature working in practice.

3. Enhance Code Comments
The existing comments are good, but could be slightly more descriptive about the precedence order:

```html

```

Technical Notes

  • The precedence (page resource first, then site-level) is the correct and expected behavior
  • The performance impact of checking $.Resources.GetMatch should be negligible
  • The logic handles the common use case where users want to keep images co-located with their content

Recommendation: Approve with documentation improvements

Great work on this enhancement! It aligns well with Hugo best practices for content organization.

@imfing imfing changed the title Support page bundle images in OpenGraph metadata feat: support page bundle images in OpenGraph metadata Jan 4, 2026
@imfing imfing merged commit 1391ebe into imfing:main Jan 4, 2026
4 checks passed
@imfing imfing mentioned this pull request Jan 29, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants