Design comparison
Solution retrospective
Someone, please explain to me why the background images never show up when i publish a website, it shows up on my editor but not on the published site for some reason, same thing happened to this site as well.
Community feedback
- @ilyesabPosted 8 months ago
Hi @Nadine-Green, I think I know why your image doesn't show.
in the file SCSS/Components/_sections.scss is where you're styling the main container and where you set the background image:
main { background-image: url("../../images/bg-intro-desktop.png"); }
The path is correct since you're jumping one up to the SCSS and then one up to the root directory where the images folder exists. however the compiled index.css has the same code but it exists directly under the SCSS folder.
So the path should be:
main { background-image: url("../images/bg-intro-desktop.png"); }
Since Sass doesn't fix the path based on where the compiled file will be generated.
It shouldn't work on your local machine on mine it works and I'm using live server. I'm assuming since live server notices that we're going up above the root directory it fixes the path. because if I open the html file without live server the background doesn't show. so just fix that line and it should work.
Hope this was helpful.
2@Nadine-GreenPosted 7 months ago@ilyesab thank you for this recommendation, but I'm not sure on how to check if it works, should I unpublish and republish the site?
1@ilyesabPosted 7 months ago@Nadine-Green not really I see you fixed it in _sections.scss. after you commit in github the frontend will be redeployed automatically. as you're using github-pages.
However you didn't recompile the scss files to generate a new index.css. that step is not included by default in github-pages. it just uses the generated index.css file directly.
You can either include the compilation of SCSS into the build pipeline which will require some github CI/CD knoweldge.
Or the easy way recompile locally and commit wait a few seconds and the background image should show up.
Marked as helpful1
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord