Images fail to appear on Github pages

Check out my GitHub page at

You can also view the repository here: https://github.com/chryspenalber/hercules

I'm encountering an issue where the images inserted through CSS are not showing up on the GitHub page, although they display fine on localhost. What could be causing this problem?

I've read articles suggesting that it might be a case sensitivity issue, but I've tried various solutions with no success. Other projects I've worked on have displayed images without any issues, so I'm puzzled about what's different in this case.

This is just one example, but it seems to affect all images on the page.

<div class="img-overlay"></div>
    <div id="topo">
        <a href="#">
            <img  src="assets/images/chevron-double-up-white.svg" alt="">
        </a>
    </div>
.img-overlay {
    position: absolute;
    top: -300px;
    left: 0;
    width: 100%;
    height: 2400px;
    background: linear-gradient(to bottom, transparent 70%, var(--bg-color) 100%), url(/assets/images/bg-hercules.jpg) no-repeat top center / cover;
    opacity: 1;
    z-index: -1;
}

Answer №1

The difference between the paths to the images is subtle yet vital:

  • img: assets/images/arrow-down-black.svg
  • css: /images/bg-athena.jpg

One path is relative, while the other is absolute from the site's root. In GitHub pages, there isn't control over the site's root.

It's recommended to use relative paths in CSS. For instance:

url(../images/bg-athena.jpg)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Spin the text inside an <li> element generated by JavaScript

I am currently working on a unique script designed to create a custom number of slices for a circle. The items in the circle are being displayed as shown in this generated circle image. This is the Javascript code I have been using: for () { men ...

When angular directives fail to function properly when added dynamically

Could someone please help me understand why the directive below is not being called? It works when I directly add the directive to the button. I even tried adding it using $timeout but still no luck. <html> <head> < ...

Ensuring that jQuery(document).ready(function() contains the appropriate content

Recently, I've been attempting to integrate a javascript gallery into my WordPress site. However, I'm encountering some confusion regarding what needs to be included in the .ready(function) to successfully run the gallery. The original jQuery fun ...

Pass a JavaScript variable to a PHP script using AJAX when a button is clicked, with a dynamically set href attribute

This is the current situation: There is a checkbox on each row of a table that represents some information An initially disabled button becomes enabled when any checkbox is checked The button is enclosed by an <a></a> tag as shown: <a>&l ...

Neither the Ajax nor the jQuery validation plugin are functioning simultaneously

My code is intended to validate all user fields before inserting data into the database. However, when I include validation code and AJAX code simultaneously, it does not work. On the other hand, both codes work fine individually. If I comment out the AJAX ...

Once the image is loaded, cropped, and displayed on the canvas, what is the best way to implement image rotation functionality for the user before converting it to base64?

My process involves cropping images to a square shape and drawing them onto a canvas. if(img.height >= img.width) { ctx.drawImage(img, 0, 0, 110, 110 * img.height / img.width); } else { ctx.drawImage(img, 0 , 0, 110 * img.width ...

handling a radius variable across various stylesheets in SASS

Recently, I started using SASS and I am very impressed with this tool. However, before diving in further, I have one question that I can't seem to find the answer to. What is the best approach for managing a variable value across multiple style sheet ...

Activate the content when selected

Is it possible for you to create a scenario where selecting one item makes other content active or visible, like on the Apple iPhone webpage? For example, when you choose the color of the iPhone 4, the model version becomes fully visible and interactive. ...

Adjusting input height with CSS in Google Chrome

When I define an input element with the following CSS properties: input { border: none; font-family: arial, sans-serif; font-size: 16px; line-height: 16px; padding: 0; } I anticipate the height of the input to be 16px, however, upon inspecting ...

Confirm the default value in a text box

I am currently working with a textbox that I have set up as shown below: <div form="form-group"> <label for="Title"> <h3>Title:</h3> </label> <div [ngClass]="{ 'has-errors': (dataProcessingEditFo ...

Having trouble retrieving the ID of a button?

I'm attempting to retrieve the ID of a button, but I seem to be getting the ID of the surrounding div instead. This is not the desired outcome. Here's my current approach: HTML <div class="container container-about container-login"> ...

What is the best way to conceal a row when a particular field is devoid of content?

Is it possible to hide an entire table row if a field is empty? For example: https://i.sstatic.net/tMW7L.png If a certain field is empty, I want the entire row to be hidden, either using JavaScript or jQuery. I have tried some methods but none of them fu ...

How can I make a zigzag pattern with CSS?

Every now and then, I come across this unique shape and corner in web design. Take a look at this sample image where I have highlighted it in red. Can anyone provide advice on how to recreate this using CSS? https://i.sstatic.net/qYWlg.jpg ...

Enhancing nvd3 Visualizations

Having some difficulty styling this nvd3 line chart. Despite getting most of it to look how I want, the tight margin between the y-axis labels and the chart is driving me mad. I managed to adjust the x-axis labels with negative line-spacing, but that trick ...

Utilizing a loop for setting variable values in JavaScript

Using both JavaScript and JQuery. Let's imagine there is an array called ListArray with various sentences inside. Sounds easy enough. Is there a way to achieve this? var List = for (var i = 0; i < 10; i++) { //iterate over an array here to c ...

Executing SendKeys on a div element with the attribute coleditable="true" in Selenium and C#

I am facing a challenge with an element that I am unable to input text into. <div class="floatstart gridcell grideditablefield" colname="Items" coltype="string" coleditable="true" val="" style="widt ...

Building an HTML page that imports XML using XSLT transformations

Looking to enhance my HTML page by adding some content in a DIV using XML and XSLT. How can I import the XML and evaluate the corresponding XSLT? I attempted using iframe, but ran into issues with resizing to fit the content. I also tried utilizing the sc ...

Steps for creating a file selection feature in Chonky.js

I recently integrated the Chonky library into my application to build a file explorer feature. One challenge I am facing is figuring out how to select a file and retrieve its unique ID when the user double clicks on it. const [files, setFiles] ...

When the width of the window is hidden, conceal

My webpage has a carousel with pictures, but on smaller devices, they do not appear properly. I am now trying to figure out how to hide the div if the width is less than 1015px. Here is the code for my div: <html> <body> <div id="myCarou ...

What are the different ways in which :style is utilized in re-frame - with brackets, curly brackets, or simply without any characters?

For my current project, I am utilizing Clojure, ClojureScript, lein, shadow-cljs, Emacs, and CIDER to develop a dynamic web application. Typically, when building the project, I initiate the command cider-jack-in-cljs in Emacs, select shadow-cljs, opt for ...