I have a pelican blog and I want to remove the .html extension from the URL. I added the following to pelicanconf.py
JavaScript
x
3
1
ARTICLE_URL ='{slug}'
2
PAGE_URL = '{slug}'
3
The problem is that invoke livereload
doesn’t serve the urls without html extension. pelican --autoreload --listen
does, but it doesn’t automatically refresh my browser on changes.
Any solution to enjoy the best of both worlds?
Advertisement
Answer
Make use of the *_URL
and *_SAVE_AS
configuration options.
E.g.:
JavaScript
1
5
1
ARTICLE_URL = '{slug}/'
2
ARTICLE_SAVE_AS = '{slug}/index.html'
3
PAGE_URL = '{slug}/'
4
PAGE_SAVE_AS = '{slug}/index.html'
5
The above does rely on the fact that webservers will provide the “index.html” file when you attempt to browse a directory directly, but this is near-universal behaviour.
You can do the above for any *_URL
setting. Further example:
JavaScript
1
5
1
CATEGORY_URL = "category/{slug}/"
2
CATEGORY_SAVE_AS = "category/{slug}/index.html"
3
CATEGORIES_URL = "category/"
4
CATEGORIES_SAVE_AS = "category/index.html"
5