Angular-App running with github pages /docs cant find assets

Im trying to host my angular app with github pages.

I build a /docs folder with the command

ng build --output-path docs --base-href /portfolio/

Problem:

The /assets folder which contains images and the translation-keys for the ngx/translate can't be found.

The /assets folder is at /portfolio/src/assets as usual and I also added it to the /docs folder.

Thats the path I use to call the pictures:

'../../../../assets/images/flags/en.png'

At localhost its working fine.

1 answer

  • answered 2022-04-28 13:52 rohithpoya

    You can build by using the below command

    ng build --output-path docs --base-href https://marcel-noehre.github.io/portfolio/

    You should give the complete path for the base href.

    Update,

    Also please add path for the image like this

    <img class="flag" src="assets/images/flags/de.png">
    

    Your image is showing in the below path,

    https://marcel-noehre.github.io/portfolio/assets/images/flags/de.png

    Attaching screenshot,

    enter image description here

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum