Problems with images in GitHub Pages

Indeed, GitHub pags serves from a subfolder https://www.example.com/subfolder.
but your baseURL in the config is just https://www.example.com/

that’s why you did not recognize it earlier…

it’s always good to have at least the same layout of subdomains/folders you plan to have in future. In fact I would consider it best practice to have the target URL in the config.

have a look at this one for possible solution using render-hooks:

and for a list of other possibilities (older): How to handle URLs when in a subfolder?