Skip to content

Add support for extensionless URLs (pretty URLs) #274

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

Merged
merged 17 commits into from
Feb 10, 2025

Conversation

reakaleek
Copy link
Member

@reakaleek reakaleek commented Jan 20, 2025

Details

This will add support for extensionless URLs.

serve command

E.g http://localhost:5000/migration/syntax.html becomes http://localhost:5000/migration/syntax

However, using .html extensions still works for backward compatibility.

generate command

In the generate command, we change the file and folder structure to always have an index.html file for every page.

e.e /migration/syntax.html becomes /migration/syntax/index.html.

This way, we can strip the /index.html segment from the URL and still serve the correct file.

an example of this is deployed at https://dwnz7p9ulv07a.cloudfront.net/migration/versioning

@reakaleek reakaleek requested a review from a team January 20, 2025 10:47
@reakaleek reakaleek self-assigned this Jan 20, 2025
@reakaleek reakaleek marked this pull request as ready for review January 20, 2025 11:00
@reakaleek reakaleek requested a review from Mpdreamz January 20, 2025 12:03
@Mpdreamz
Copy link
Member

In the generate command, we change the file and folder structure to always have an index.html file for every page.

e.e /migration/syntax.html becomes /migration/syntax/index.html.

I am not sure this aids in keeping the docs simple for new contributors.
We kind of lose that 1:1 mapping of URL to file: turning /migration/syntax.md to /migration/syntax/index.html

Don't really have a full fledged opinion on this (yet) though need to mull it over a bit ⌛

@reakaleek
Copy link
Member Author

reakaleek commented Jan 20, 2025

In the generate command, we change the file and folder structure to always have an index.html file for every page.

e.e /migration/syntax.html becomes /migration/syntax/index.html.

I am not sure this aids in keeping the docs simple for new contributors. We kind of lose that 1:1 mapping of URL to file: turning /migration/syntax.md to /migration/syntax/index.html

Don't really have a full fledged opinion on this (yet) though need to mull it over a bit ⌛

Just to give some context: I was actually highly inspired by https://middlemanapp.com/advanced/pretty-urls/

generally, IMHO this is just the representation on the server. I assume developers or authors will not check the files on production and check if there is a 1-to-1 mapping.

technically, I need to do this to simplify the the cloudfront lambda function and being able to just append /index.html to the origin request.

@reakaleek reakaleek changed the title Add support for extensionless URLs Add support for extensionless URLs (pretty URLs) Jan 20, 2025
@bmorelli25
Copy link
Member

bmorelli25 commented Jan 22, 2025

@Mpdreamz
Copy link
Member

Mpdreamz commented Feb 4, 2025

This LGTM for the most part!

I think we should make MarkdownFile as the index property through an IsIndex prop on the class.

We now have quite a few places where we handle index.md specially through a magic string however

- folder: mover
  children:
    - file: first-page.md
    - file: second-page.md

Here first-page.md is the index file for the mover folder.

Copy link
Member

@Mpdreamz Mpdreamz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, we can address my feedback in a follow up PR.

@reakaleek
Copy link
Member Author

This LGTM for the most part!

I think we should make MarkdownFile as the index property through an IsIndex prop on the class.

We now have quite a few places where we handle index.md specially through a magic string however

- folder: mover
  children:
    - file: first-page.md
    - file: second-page.md

Here first-page.md is the index file for the mover folder.

Could you elaborate on this?

I tried to understand this statement.

but it looks like this works here https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/274/testing/mover/first-page/, if I compare it to the behaviour of https://elastic.github.io/docs-builder/testing/mover/first-page.html

@reakaleek
Copy link
Member Author

This should wait for #442 before being merged.

@reakaleek reakaleek merged commit 513f300 into main Feb 10, 2025
5 checks passed
@reakaleek reakaleek deleted the feature/extensionless-urls branch February 10, 2025 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants