thegeeklab / hugo-geekdoc

Hugo theme made for documentation

Home Page:https://geekdocs.de

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

image url works on localhost but not on Github Pages

Alex-Space opened this issue · comments

commented

Hi! All my images in /static/media folder, as you suggested here #88 and in my .md files I use basic markdown for images like this - ![Mortar Team](media/Items/BTNDemolish.JPG) . It works fine on my localhost, but not when I opened it on Github Pages in subdirectory https://alex-space.github.io/btxwiki/%D0%9F%D1%80%D0%B5%D0%B4%D0%BC%D0%B5%D1%82%D1%8B/%D0%A0%D0%B0%D1%81%D1%85%D0%BE%D0%B4%D0%BD%D0%B8%D0%BA%D0%B8/Mortar-Team/

Image displays on Github Pages only if I change from this:
![Mortar Team](media/Items/BTNDemolish.JPG)
to this:
![Mortar Team](/btxwiki/media/Items/BTNDemolish.JPG)

But the problem is that then it doesn't work on my local server. What solutions to the problem exist?
I like the idea to use /static/media folder as images storage. I have pictures very often repeated and there is no need to duplicate them, storing them all in one place is the best option for my project.

Hi, there are two issues:

  1. You can't use http://localhost (domain root) for local testing while deploying to a subpath https://alex-space.github.io/btxwiki on the remote site https://github.com/Alex-Space/btxwiki/blob/main/config.toml#L1-L2 because a subpath deployment affects the static directory and it cant work for both cases at the same time.

  2. Deploying to a subpath in general is not recommended nor supported, please read https://geekdocs.de/usage/getting-started/#subdirectories

commented

I got it, thanks for the answer! In this case, the only option is to create another Github account and use its domain without creating a subdomain. Otherwise, I simply won't be able to use any other sites in my Github Pages.

I thought I was having a permutation of this issue, but it was not the case. For posterity, if you're setting up GitHub Actions for GitHub Pages, and using a git submodule, make sure you have:

npm install
npm run build