Skip to content

Instantly share code, notes, and snippets.

@emmahsax
Last active March 5, 2025 16:38
Show Gist options
  • Save emmahsax/b51e793dc1348e7ce75646427508dfd8 to your computer and use it in GitHub Desktop.
Save emmahsax/b51e793dc1348e7ce75646427508dfd8 to your computer and use it in GitHub Desktop.
Linking to images, resources, CSS, and JS within Jekyll
@Antboi123
Copy link

Antboi123 commented Mar 5, 2025

So, if i want to add an image through github for my page, i should use<img src="/assets/Screenshot 2025-03-05 122037.png"\>? I just dont really want to waste my time grinding on images that aren't working . I have th files ready to upload but need to find out how to make the images work.

@emmahsax
Copy link
Author

emmahsax commented Mar 5, 2025

All of these guidelines are assuming you have a Jekyll-based static site, so like GitHub Pages or similar. It may also work for other static site generators, like Hugo, but I'm not sure.

Assuming your image is in your Git repository at /assets/Screenshot 2025-03-05 122037.png, then yes, you can use <img src="/assets/Screenshot 2025-03-05 122037.png"\> to make the image show up on the HTML page. Based on my testing, I'd recommend <img src="/assets/Screenshot 2025-03-05 122037.png"> with no \ at the end on Markdown pages.

I believe I've also used this to link to images on regular Markdown pages (e.g. READMEs) hosted on GitHub, so you can try that, too! Does all of this information help, or do you need more guidance? If you'd like more help, can you please try describing your situation more, or providing me to a link to your repository?

@Antboi123
Copy link

Thanks for the help. I already resolved the problem and now working on other parts. It seems that the spaces between the letters or the name of the screenshot itsell was the issue. If you want to look through my code, you can visit it here: https://github.com/Antboi123/fvwjervesamvjksfcneajl9823v9yh67y5edfy6u7iyuj9oyg543d23456765g4f3dde4fr5gt6hy7ju87hygtfderftgyhu7ji8

@emmahsax
Copy link
Author

emmahsax commented Mar 5, 2025

Oh, yeah I didn't even catch that. I tested it with images I have in my repos, which all have _ or - instead of spaces.

@Antboi123
Copy link

Currently dying to coding rn... Working on the rest of the index.html, gonna die to the page links for sure...

@Antboi123
Copy link

To make it even worse, gonna add multiple languages...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment