The prioritization of settings in the official documentation is not clearly outlined, so this guide organizes the process.
Environment
- Hugo: v0.137
- PaperMod: v8.0
$ hugo version
hugo v0.137.0-59c115813595cba1b1c0e70b867e734992648d1b+extended windows/amd64 BuildDate=2024-11-04T16:04:06Z VendorInfo=gohugoio
$ git submodule foreach 'git log -1 --oneline'
Entering 'themes/PaperMod'
3e53621 (HEAD -> master, origin/master, origin/HEAD) Update PaperMod version to v8+ in license.css and license.js
Conclusion
Configure a fallback image placed in the static/images directory1 by specifying it in the params.images section of hugo.yaml:
params:
images:
- "images/default-cover.jpg"
Verification Steps
Local Environment
-
Run the
hugocommand to build the site and verify the following:- The file
public/images/default-cover.jpgis generated. - The
public/index.htmlfile includes the following<meta>tag:
<meta property="og:image" content="https://example.com/images/default-cover.jpg"> - The file
After Deployment
- Use tools like OpenGraph to check the deployed URL and confirm that the thumbnail displays correctly.
Explanation
The OpenGraph image selection logic in PaperMod follows this order:
The image selection prioritization is as follows:
- An image specified in the
cover.imagefield of the front matter. - The first image specified in the
imagesfield of the front matter. - Images in the Page Bundle whose filenames include
feature,cover, orthumbnail. - The first image specified in
site.Params.images.
Thus, the hugo.yaml setting is used as the fallback in this hierarchy.
References
-
In Hugo, files in the
staticdirectory are directly reflected in the public URL. ↩︎