Skip to content
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

[Shock] - Base path data doesn't work as expected on lower inherited directories #151

Open
matthew-carroll opened this issue Jul 22, 2024 · 0 comments

Comments

@matthew-carroll
Copy link
Contributor

matthew-carroll commented Jul 22, 2024

EDIT:
In addition to the details below, the term basePath is probably being mis-used. Typically, a basePath refers to something added, not removed. A website might be deployed such that all pages sit under an added path that the source code doesn't know about, e.g., GitHub pages adds a path: github.com/my-org/posts/hello-world/. The basePath in this case would be my-org/.

The behavior that currently exists in basePath is more like a path rewrite. We should better reflect this distinction.


The basePath property can be applied to a page to replace the page's directory location with the given basePath. This is useful, for example, if all blog posts are stored under source/posts/ but you don't want the posts/ to appear in the URL.

/source/posts/hello-world.md -> mydomain.com/hello-world/

The basePath property can be defined in a _data.yaml file to easily change the base path for all pages in that directory. However, due to data inheritance, this approach doesn't work as expected for pages deeper within the directory hierarchy.

Example 1:

Imagine that the example above needed to group more than just one file for hello-world:

source/
  posts/
    hello-world/
      index.md
      header.png

In the above case, we'd still want the url to be mydomain.com/hello-world/ but instead we get mydomain.com/index.html. This is because the hello-world/ is now a directory, which is treated as part of the URL path, and is replaced by the basePath of /.

Example 2:

Imagine that we have a multi-level hierarchy of posts, which should legitimately have a hierarchy of URLs, but we want to remove
the top level posts path:

source/
  posts/
    news/
      hello-world.md
    trending/
    archive/

By default, the hello-world.md page would deploy to mydomain/posts/news/hello-world/, but we'd like it to appear at mydomain/news/hello-world/.

Technically, this goal could be a achieved by setting the basePath in news/, trending/, and archive/ instead of under posts/. However, this only moves the problem one level deeper.

Instead, the more appropriate thing to do is have basePath apply to whatever level in the directory system where its defined, but then not effect any pages or assets lower down in the directory hierarchy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant