-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for extensionless URLs (neither .html nor trailing slash)? #809
Comments
If you want to generate the file Lektor generates a folder per page with an I think the web server configuration method will cause you a lot less pain. May I ask why you want this feature? |
To be clear, I want to generate a file called I think if I were choosing ideal URLs for a project list and projects, I would use My use case is mainly deployment to GitHub Pages, which already automatically rewrites |
FWIW, I understand if you don't want this feature in core, but I would be satisfied by a plugin architecture that lets me do these two things and nothing else:
I wanted to see if there were better ways to do it, though. (edit: There's also one more problem I forgot with the rewriting solution, which is that silently rewriting |
So, there are a few things to unpack. Firstly You can add your own So if there is an HTML file GitHub pages will automatically "add" the If that works it's probably easier for you to do that and write a proxy in front of your dev server that fetches the HTML for you. If this is to be added as a core feature I think it should probably just be the
I think this would be the most consistent way to do it. There may be room for a |
OK, after reading that, I figured out how to monkey-patch Lektor from a plugin to basically work for my use case: https://gist.github.com/betaveros/fcf9e54706acc241eb16604debe4901f So I think this will work for now. However, let me at least try to argue that this behavior is not that vendor-specific:
I'll let you decide if this issue is still worth considering, though. Thanks! |
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 possible way to combine the behavior with #344 could be to define a new system field Line 417 in 1438f54
This new field would describe how to convert the slug into a component of the URL path, given the slug and whether it's the last segment of the path. It can take one of the following values:
I think it would be good if there's a project-wide setting that provides a default value for this field, and then individual pages can override it. Maybe also allow a page to set a value for its children, similar to I think if we can fully adopt the |
Slug styles specify how slugs are turned into file and directory names in the URL path. This is roughly based off the design in lektor#809 (comment). As is, this PR fixes lektor#344 and deals with the tricky "global" part of doing lektor#809 properly. It also enables pages with dots in their slugs to be paginated and fixes some issues with the dev server resolving descendants of such pages incorrectly. It is still a prototype, though (I have only done some casual manual testing and yet to write any tests). In addition to a sitewide default setting and per-page setting, we would likely also want datamodels to be able to specify the slug style of their pages and/or their child pages. To stay similar to the current way `slug_format` can be configured, it seems we should also allow datamodels to specify the slug styles of their children, but as mentioend in lektor#806 that behavior is a little strange and worth reconsidering, so this PR doesn't try to implement any such behavior.
Does anybody have thoughts or feedback on the above design and PR? |
I don't see this as a core feature, that is, part of the slug logic. To me this is simply "URL faking", something that needs explicit support from the web server. If it lands in lektor core that's all fine, but it should be labelled as such, not mingled with slugs (I think this should also apply to the code as much as possible). I haven't reviewed the PR yet, but I will, sometime next week I hope. |
Cool. Yeah, the PR does not actually do the URL faking part of this issue; it just gives you an option to let something with slug |
For requests, isn't apache (multiviews) also able to add 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
|
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 jekyll/jekyll#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...)
The text was updated successfully, but these errors were encountered: