question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for extensionless URLs (neither .html nor trailing slash)?

See original GitHub issue

I would like to generate a static site in which I have files like blog/post-name.html, but the generated URLs to them have neither .html nor a trailing slash and look like, for example, example.com/blog/post-name. (Although this requires support from the web server, it’s pretty common and easy to set up; for example, GitHub Pages supports it directly with no configuration. It doesn’t seem to be commonly supported in other static site generators, but Jekyll supports it — there used to be a clear section in the Jekyll documentation explaining this, but it seems to be sort of absorbed into the overall documentation now; see https://github.com/jekyll/jekyll/issues/156 for more discussion and motivation.)

Does Lektor support this? If not, is it possible to add support, or at least expose enough API to make this possible to implement in a plugin? I’ve poked around trying to write a plugin and am very unsure if the current plugin API supports this. For example, I can create an extra VirtualSourceObject for every Record and make the URL resolver resolve extensionless URLs to it, and I imagine I could just change every place URLs are generated in my website templates to use these URLs instead, but I don’t think I can avoid building a separate artifact at a separate location, nor do I think I can make my new source just fallback to my old source’s generated file.

If this sounds like a feature you don’t have but would accept, I am extremely willing to write code for this 😃 (Lektor’s CMS looks amazing, plus my blog currently runs on a custom Hugo fork that I don’t want to maintain indefinitely…)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
xlotlucommented, Sep 3, 2020

I don’t really have an objection to this being in core, I guess file extensions are increasingly irrelevant to anyone but old dinosaurs.

The complicated stuff would be: a) finding a config name for it 🙄, and b) making sure the logic won’t blow up once #344 is fixed. There’s probably other places that will get tripped, relative urls will need fixing as well, and the devserver part will need to know if that’s an actual extensionless file or a .html. The current gist is naive in this respect, but hey, so is lektor core for now.

0reactions
testbirdcommented, Jan 8, 2021

For requests, isn’t apache (multiviews) also able to add /index.html to an extension-less slug if it finds a directory?

So, wouldn’t lektors a-folder-per-page approach (on disk) be just fine. And the only thing missing would be a lektor option that allows it to drop /index.html | .html from internal links in the generated pages?

webserver_supports_clean_URLs = true?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove html php extension and trailing slash at the ...
I want to remove the html and php extension from url and then I want to add trailing slash. So far I have...
Read more >
How can I add a trailing slash at end of URL? - Joomla! Forum
Does anyone know how to add a trailing slah at the end of the Joomla URLs? It seems to be either no suffix...
Read more >
Modify rewrite rule that strips .html from urls to ad trailing slash
Hi All, I got this little gem from here a while ago to strip .html from the end of and inside all my...
Read more >
Extensionless URLs with Adobe Experience Manager
If you are using the rest of this custom solution, DO NOT check “Strip HTML Extension.” To replace “.html” extensions with a forward...
Read more >
Missing trailing slash in URL on subpages resulting in Moz PA ...
`#removes trailing slash if not a directory RewriteCond ... forward request to html file, but don't redirect (bot friendly).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found