Skip to content

How do I add thumbnail images to the blog posts? #256

Answered by vahidtakro
reignbeox asked this question in Q&A
Discussion options

You must be logged in to vote

tldr: how do I add a thumbnail image to the blog post list?

simply add these lines to your ListLayout.js / index.js file after </time></dd> line:

    {images ? (
      <Image
        className="rounded object-cover"
        src={`/_next/image?url=${images}&w=640&q=20`}
        slug="slug"
        title={`${title}`}
        alt={`${title}`}
        layout="responsive"
        placeholder="blur"
        blurDataURL={`/_next/image?url=${images}&w=16&q=1`}
        width={640}
        height={400}
      />
    ) : null}

you should also include images into your frontMatter:
const { slug, date, title, summary, tags, images } = frontMatter

and import nextjs Image Component at top of the page(s):

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@reignbeox
Comment options

@reignbeox
Comment options

@aloisdg
Comment options

@vahidtakro
Comment options

@reignbeox
Comment options

Answer selected by reignbeox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants