[Vuejs]-Github pages are not showing images

0๐Ÿ‘

So webpack is able to find the images and process them as resources, you should reference the assets (images) via relative paths, not absolute paths.

So, considering a file at /src/components/home.vue with images at /src/assets (being / the project root), instead of:

<img class="home__img__header" src="src/assets/craft-beer.jpg" alt="Craft Beer">

Use:

<img class="home__img__header" src="../assets/craft-beer.jpg" alt="Craft Beer">

Naturally, in other files, change the relative path accordingly.

0๐Ÿ‘

For the images to work with Vue the generated file there are few ways.Here is an SO link on the same.

How to import and use image in a Vue single file component?

What you will want to do here is something like this.

<img class="home__img__header" src="~src/assets/craft-beer.jpg" alt="Craft Beer">

This lets the webpack know about the image being an asset and generate its path appropriately.

Leave a comment