3

To deploy project on github pages I am using this command:

ng run ticket-shop:deploy --base-href /deploy/

My problem is that gh-pages has some serious problems with calling assets folder. It always skips '/deploy/' part. I have found many other questions with the same problem on stack and github but none seems to solve it. Difference in my question is that after hardocoding '/deploy/' into the assets url it still misses some images and loads others.

How it should be according to what I have read:

According to what I have read, calling assets folder from css needs to be done using relative path, so it should be like this:

background-image: url("../assets/foobar.jpg");

but it doesn't work, gh pages is looking for assets under this address:

https://me.github.io/assets/foobar.jpg

instead of

https://me.github.io/deploy/assets/foobar.jpg

My workaround

As I am losing my patience for this because I can't find any answers for this problem I have hardcoded the '/deploy/' part, it is really 'unclean' but at least it somewhat works. What is funny and here is my variation from other questions - it works for some images and for others not.

I have every url in css like this:

background-image: url("/deploy/assets/foobar.jpg");

and it loads every image except one, I have no idea why, for one specific image it is still looking under:

https://me.github.io/assets/neverlucky.jpg
askstackoverflow
  • 301
  • 3
  • 11

1 Answers1

0

I solved this problem by using a "~" char:

background-image: url("~/assets/foobar.jpg");
Maxim Pyshko
  • 551
  • 4
  • 14