Skip to content

How to implement Featured / Hero Image for Blog Posts (and other pages) #427

Closed
@monikappv

Description

@monikappv

When we are creating a blog index page on vuepress we want to show the hero/featured image of the blog post so that we have a nice image (humans love pictures!) and that image is specified by blog post author (not by index page creator!)

When creating a blog post I want to have the images in the same directory so that all the content is in one place and easy to see and reference

NB: this is also applies to other pages e.g. job or product pages where we may wish to show their featured image elsewhere

The challenge: the preference to keep content in same directory as post and to reference in other pages (e.g. blog index) may be in tension!

  • Other pages only have access to frontmatter plus rendered content ... (this is just how static site generators work and vuepress in particular) => there's no way to get a list of images used in a page and e.g. use the first one
  • Assets pipeline of vuepress "mangles" the paths of files (because web assets)
  • Frontmatter therefore can only reference files in public

Reference:

vuejs/vuepress#165
https://stackoverflow.com/questions/51322398/linking-to-assets-in-vuepress
https://vuepress.vuejs.org/guide/assets.html#public-files

Acceptance

  • frontmatter images of blog posts showing up on other website pages

Tasks

  • Work out if we want to reuse blog post main image elsewhere
  • Can we do that w/o it being in public => ANS: No => have to move that image to public
    • TODO: evidence for that ...
  • What are our options then?
    • Don't have featured image
    • Move featured / hero image to public directory
      • Can we have sub-directories of public
  • Implement that option

How do we deal with blog posts with no image in blog listing page?

  1. just show a placeholder image (e.g. the logo)
  2. To have a layout that support image and non-image blog posts

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions