Github: image URLs broken on deploy to gh-pages

Hi,

Been banging my head on this for a while now.

I’ve a new site on GihHub pages. It will be under the main user domain avastmick.github.io
Site config

baseURL = "https://avastmick.github.io/teaching/"

Locally everything is fine locally. But on deployment the URLs to the images are broken. They always resolve in the HTML to /images/path_to_file and not as other assets do teaching/path_to_file – I was expecting to see teaching/images/path_to_file

All my site assets are stored under static - so static/images/filepath/file_name

Example:
Markdown:

![](/images/lessons/intro-to-prog/IDLE-Editor.png?classes=border,shadow)

HTML:


<p><img src="/images/lessons/intro-to-prog/IDLE-Editor.png?classes=border,shadow" alt="" /></p>

<iframe id="slideFrame" src="/teaching/none.html" style="width:100%;height:30em; border:0px"></iframe>
<div id="slideContent">
	<link rel="stylesheet" href="/teaching/revealjs/css/reveal.css">
	<link rel="stylesheet" href="/teaching/revealjs/css/theme/moon.css" id="theme">
	<link rel="stylesheet" href="/teaching/revealjs/lib/css/zenburn.css">

I am using the DocDoc Theme, as this will be a teaching resource site with a lot of slides.

Now, if I set canonifyURLs = true the images are resolved correctly, but then I find all the reveal.js links are broken and slides do not resolve.

I’ve tried a variety of combinations of baseaURL:

Site config (obviously not all at once!)

baseURL = "/teaching/"
# or 
baseURL = "https://avastmick.github.io/teaching"
# or 
baseURL = "/"

I’ve no idea how to move this on. Any help would be appreciated.

M

Try setting your baseURL to:

baseURL = https://avastmick.github.io/

Images under /static/images/ always resolve under {{ .Site.BaseURL }}/images/

The variations you tried break the src of your images.

EDIT
Just realised that this project is published in a subdirectory.
In this case add /teaching/ at the front of your images src url structure. It should work.
But you would also need to include /teaching/ in your internal links.

EDIT 2
baseURL has issues with subdirectories.

1 Like

Ahh, okay - so it’s a bug then… :slightly_smiling:

Thanks for the information. That works, though it won’t work in the longer term as the content won’t be portable.

I’m only setting up right now, so not much content is loaded, so no dramas. Still, I think I’ll create an organization and then there will be no need for a subdirectory… That will save time later on…

:beers:

1 Like

Not a bug per se. There are other people who experienced this. If my suggestions or variations of those) don’t work try searching the forum.

Also another way to troubleshoot, would be to use your browser’s dev tools and modify the src of your missing images on the fly and see where they actually resolve. eg. add /teaching/

That should tell you how you need to configure the img src url structure and how to set up your baseURL

1 Like