meeb / django-distill

Minimal configuration static site generator for Django
MIT License
441 stars 35 forks source link

Prefix option for distill-local #49

Closed Ash-Crow closed 3 years ago

Ash-Crow commented 3 years ago

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 3 years ago

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?

Ash-Crow commented 3 years ago

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

meeb commented 3 years ago

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?

Ash-Crow commented 3 years ago

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 3 years ago

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

Ash-Crow commented 3 years ago

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 3 years ago

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