meeb/django-distill

Prefix option for distill-local

Closed this issue · 7 comments

Hi, I tried to use Django-distill to generate a site that I would like to host on Github Pages.
The problem is that Github pages for projects uses URLs that use the format https://<organization>.github.io/<repository> instead of serving from the root, and django-distill generates URLs that would only work if both the pages and the statics are served from the root.

Would it be possible to add a "prefix" option to distill-local.py to automatically fix the URLs to the matching format ?

(For example, if right now the command generates a path like "/tags/index.html" or "/static/css/main.css", with the --prefix=my-project parameter on the command line it would generate "/myproject/tags/index.html" and "/myproject/static/css/main.css" instead.)

meeb commented

Could you not solve this by just modifying your URLs to include the /myproject/... prefix and change the STATIC_URL to be /myproject/static/ yourself?

If I do that, it creates a "myproject" directory where it stores the generated files...

meeb commented

I must admit I've never used Github pages. There must be a more sensible option that hacking all the URLs for a site. If you're using Github actions to build the site could you do a mv build/myproject docs at the end of it?

This is my first time using Github pages too and I hadn't think of Github Actions to build the site. This worked, thanks !

meeb commented

Excellent, glad you found a solution. Any other issues or can we close this?

You can close the ticket :)

Maybe it could be useful to document how to do it though? If so, here is the config file I used for the action https://github.com/entrepreneur-interet-general/django-dsfr/blob/main/.github/workflows/deploy-doc.yml

meeb commented

Cheers, I might well put that action somewhere in the examples!