eudicots / Cactus

Static site generator for designers. Uses Python and Django templates.
BSD 3-Clause "New" or "Revised" License
3.46k stars 315 forks source link

Serve site from a non-root path #246

Open chrisparana opened 8 years ago

chrisparana commented 8 years ago

Is there a way to configure a site that will not be residing at the root path? All my URLs/static are broken because it's assumed that it starts at root.

ghost commented 8 years ago

Just to clearify, you've setup a domain and the cactus page resides in a subdir like domain.tld/mycactus_site/ ?

Maybe the Site URL config feature is your friend then: Site URL.

chrisparana commented 8 years ago

Yes, it's a work provided staff page, each user has their own domain.tld/username/ page… adding the url to Site URL in the config didn't seem to make a difference. For example static items urls all still start at /static/, which of course, won't work.

ghost commented 8 years ago

You are right site-URL isn't of much use here. I guess trying "Page and static prefix support proposal" is your best bet atm.

kamalx commented 7 years ago

I was looking for a solution to this same problem and couldn't find anything yet. In that regard, the only thing that has worked for me is to use relative URLs for static resources.

Would I run into any potential problems down the line if I use src="static/images/myimage.png" instead of src="{% static 'images/myimage.png' %}" on a site hosted in a non-root dir?

I am also not using the {% url '' %} tags for links; I use relative links directly instead. I am not sure of the implications of that completely yet but it has worked perfectly for my relatively small website with a flat hierarchy pretty seamlessly. I can host the generated websites from any subdir I want without issues.