Closed gregsadetsky closed 1 year ago
If I understand your issue correctly this is more of a Django question than distill question. Specifically, how to run Django in a "subfolder" (or with a global URI prefix). Given distill just does whatever Django is doing, the issue really is to make Django work with the root of the project at /some-repo-name/
, then distill it.
The two most common ways are tweaking settings.FORCE_SCRIPT_NAME
:
https://docs.djangoproject.com/en/4.2/ref/settings/#force-script-name
or by using a global URL prefix:
urlpatterns = [path('some-repo-name/', include(urlpatterns))]
You'll probably still have to edit STATIC_URL
as well. You can test all of this in the Django development server (runserver
) before distilling the site.
If you want the super hacky way, you can could try using entirely relative asset paths rather than absolute paths and set a <base>
HTML tag in your template, but generally I'd go with FORCE_SCRIPT_NAME
if it was me.
Thank you!
I was a bit blanking yesterday. Here's how I made it work:
reponame
and I'm deploying to https://gregsadetsky.github.io/reponame/
reponame/static/
urls.py
: path("reponame/", include("core.urls"))
i.e. make all urls be /reponame/something
django-local docs
, I will get docs/reponame/...
and all generated files will be inside of that subdirdocs/
i.e. the physical files/urls would be at https://gregsadetsky.github.io/reponame/reponame/index.html
for examplemv
everything from inside docs/reponame/
to docs/
, and then rm -rf repo/reponame
(the empty directory)Did I make it a lot more complicated than it needs to be? :-) I mean in the end it's just 2 bash lines. It still feels a bit weird to do that?
That doesn't sound too weird. I've not used GitHub pages myself, so if it has that restriction and it's not editable then I would assume you'd need to tweak the path post-rendering. If it helps, Cloudflare pages works very nicely with django-distill
and has a free tier...
Thanks for the great package!
I'm currently deploying my static, django-distill powered site using github pages
The deployment url looks like this:
https://gregsadetsky.github.io/some-repo-name/
Because of this (i.e. not deploying to
/
like you'd typically do), things get... weird/complicated :-) I've done tests withSTATIC_URL
, tried to add prefixes inurls.py
and even manually in my template html files. Even did a bit of terrible bash scripting to move stuff around in the generated directory.Nothing feels natural or good. What would you suggest as the correct way of making this work? I'd want template
<a href="{% url ... %}">...</a>
links inside of my templates to work, and for images included using<img src="{% static ... %}">
to work as well.Thank you!