Skip to content

Make index suffix on URLs optional #442

@james-nash

Description

@james-nash

Currently, where a directory contains an index.mdx file, Mosaic will ensure that the corresponding URL ends in index. For example:

  • Source: foo/bar/index.mdx
  • URL: https://example.com/foo/bar/index

Requests to the URL https://example.com/foo/bar will be redirected to the corresponding https://example.com/foo/bar/index URL.

It would be nice if there was an option to change the behaviour so that it becomes:

  • Source: foo/bar/index.mdx
  • URL: https://example.com/foo/bar
  • https://example.com/foo/bar/index would be a permanent redirect to https://example.com/foo/bar

This is the behaviour we would like for the Salt site as:

  • We get more succinct URLs (easier to read, share verbally, guess, etc.)
  • It's more inline with how out-of-the-box Next.js behaves and indeed many other site generation tools where index.md|html|whatever files tend to be served up at URLs whose path omits the index part.

I suggest that this becomes an opt-in option though (perhaps via mosaic.config.js?), so that other Mosaic-based sites don't suddenly have all their URLs change upon upgrading.

Note that the non-index-suffixed URLs would also need to be reflected in any auto-generated links for site navigation, breadcrumbs, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions