Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular image not showing after deploying to Github Pages

I'm new to Angular. I recently deployed a sample webpage to Github Pages. I was successful at deploying but images that are visible on localhost are not showing up. Instead, I'm getting a 404 logged on the console.

This is the component containing the img :

home.component.html :

<div>
    <img src='assets/images/birthday.jpg' alt='Happy Birthday' width="385px"/>
</div>

My directory structure is :

   |src
   |--app
   |--assets
    |---images
     |----birthday.jpg

The directory structure in the dist folder is :

   |dist
   |--happy-birthday
    |--assets
     |---images
      |----birthday.jpg

I'm deploying using angular-cli-ghpages package. My Angular version is 10.0.14.

like image 386
muskaanshraogi Avatar asked Jun 08 '26 00:06

muskaanshraogi


1 Answers

Try to use /assets/images/birthday.jpg.

like image 131
0x6368656174 Avatar answered Jun 10 '26 15:06

0x6368656174