You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
3.1 KiB

4 years ago
  1. +++
  2. title = "Post Images"
  3. description = "Add large hero images without touching an image editor."
  4. categories = ["experience"]
  5. tags = ["performance", "imaging", "graphics", "posts"]
  6. features = ["code highlighter", "snippets", "related content"]
  7. [[copyright]]
  8. owner = "Josh Habdas"
  9. date = "2019"
  10. license = "agpl-3.0-or-later"
  11. +++
  12. {{< figure
  13. src="/images/watercolor_pTIyYTqAlF8_w1440h700.jpeg"
  14. alt="Map image"
  15. lqipsrc="/images/watercolor_pTIyYTqAlF8_w936h455.jpeg"
  16. caption="Sample image placement. Not the real deal."
  17. >}}
  18. Add visual appeal to your posts with post images. Post images appear above post content and leverage {{< external href="https://gohugo.io/content-management/image-processing/" text="Hugo Image Processing" />}} and [Lazy Loading](../lazy-loading) to provide fully automatic, lazy-loaded responsive images with <abbr title="Low-Quality Image Placeholders">LQIP</abbr> and built-in art direction.
  19. Using post images requires some opinion with regard to the structure of your content. To create a post with a post image you must:
  20. 1. Group image and content in a {{< external href="https://gohugo.io/content-management/page-bundles/" text="Page Bundle" />}} as shown below.
  21. 2. Update post {{< external href="https://gohugo.io/content-management/front-matter/" text="Front Matter" />}} as described below.
  22. An example page bundle might look like:
  23. ```
  24. ├── archetypes
  25. ├── content
  26. │ └── post
  27. │ └── secure-your-digital-life
  28. │ ├── images
  29. │ │ └── florian-klauer-119557-unsplash.jpg
  30. │ └── index.md
  31. ├── layouts
  32. ```
  33. With a `header` image specified in `index.md`:
  34. ```toml
  35. [[resources]]
  36. src = "images/*119557*"
  37. name = "header"
  38. ```
  39. {{% hackcss-alert type="info" %}}**Tip:** Orientation is not significant. For optimal display use larger images.{{% /hackcss-alert %}}
  40. Add an image caption showing the image title:
  41. ```toml
  42. [[resources]]
  43. src = "**291607-unsplash.jpg"
  44. name = "header"
  45. title = "Ottawa road in the evening" # adds image caption
  46. ```
  47. Add [Structured Data]({{< relref "structured-data" >}}) using {{< external "https://gohugo.io/content-management/page-resources/#page-resources-metadata" "Resources Metadata" />}} to improve accessibility:
  48. ```toml
  49. [[resources]]
  50. src = "**291607-unsplash.jpg"
  51. name = "header"
  52. title = "Ottawa road in the evening"
  53. [resources.params.meta]
  54. description = "Light trails depicting speed" # adds alt text and image meta
  55. creator = "Marc-Olivier Jodoin" # updates caption and adds image meta
  56. ```
  57. Continue adding metadata to improve accessibility:
  58. ```toml
  59. [[resources]]
  60. src = "**291607-unsplash.jpg"
  61. name = "header"
  62. title = "Ottawa road in the evening"
  63. [resources.params.meta]
  64. description = "Light trails depicting speed"
  65. creator = "Marc-Olivier Jodoin"
  66. sameAs = "https://unsplash.com/photos/NqOInJ-ttqM/" # also updates caption
  67. license = "https://unsplash.com/license" # attribution not required
  68. contentLocation = "Ottawa, Canada"
  69. keywords = ["light trail", "building", "speed", "night"]
  70. ```
  71. Supported metadata in examples above. Adjust display using [Custom Styles]({{< relref "custom-styles" >}}).