Flutter-Bounty-Hunters / static_shock

A static site generator for Dart.
MIT License
59 stars 5 forks source link

[Shock] - Support root URL paths #50

Open matthew-carroll opened 11 months ago

matthew-carroll commented 11 months ago

When deploying Static Shock to GitHub pages, we ended up with a root URL of https://flutter-bounty-hunters.github.io/static_shock/

This means that when we expect an asset path of /styles/theme.css, the actual path is /static_shock/styles/theme.css. Therefore, assets fail to load.

Static Shock should make it possible to account for a global base-path in the URL for all pages and assets.

hifiaz commented 4 weeks ago

@matthew-carroll any guide to make it as actual path?

matthew-carroll commented 4 weeks ago

@hifiaz is this something you need? If so, can you please provide details about what you're trying to do, what's working, and what isn't working?

hifiaz commented 4 weeks ago

i try your great work on this repo https://github.com/hifiaz/lthfi but i think because this not in main so assets css, image, and default path for '/' routing to https://hifiaz.github.io actually correct path is https://hifiaz.github.io/lthfi/

matthew-carroll commented 4 weeks ago

@hifiaz I think I'm going to need some specifics. Please choose 1 broken image path and post:

hifiaz commented 4 weeks ago
  1. actual image is https://hifiaz.github.io/lthfi/images/nav-search.png but got https://hifiaz.github.io/images/nav-search.png
  2. actual path https://hifiaz.github.io/lthfi/about =>> https://hifiaz.github.io/about
  3. actual css https://hifiaz.github.io/lthfi/css/main.css =>> https://hifiaz.github.io/css/main.css
matthew-carroll commented 4 weeks ago

Thanks. I'll ship a fix for this soon.

matthew-carroll commented 4 weeks ago

@hifiaz - I looked into this a little bit more. I think this might be more of a user issue rather than a static_shock issue.

Can you please check your HTML files and remove the leading "/" from the paths?

For example, change "/images/nav-search.png" to "images/nav-search.png".

This changes from an "absolute" path to a "relative" path. By using relative paths, GitHub pages should be able to resolve them correctly.

hifiaz commented 4 weeks ago
  1. when i set "images/nav-search.png" its work on root build but not work when sub like https://hifiaz.github.io/lthfi/about/ also css not rendered on sub

    Screenshot 2024-05-31 at 14 50 01 Screenshot 2024-05-31 at 14 50 28
  2. navigation url from _data.yaml keep redirect to main https://hifiaz.github.io/ actually must be https://hifiaz.github.io/lthfi

    Screenshot 2024-05-31 at 14 48 33

so from this case only index.html on main root build folder working correctly