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

Absolute paths: its possible? #434

Closed
renatorib opened this issue Sep 9, 2016 · 1 comment
Closed

Absolute paths: its possible? #434

renatorib opened this issue Sep 9, 2016 · 1 comment

Comments

@renatorib
Copy link

renatorib commented Sep 9, 2016

How I can set absolute paths?

I have this page:

pages/
  foo/
    bar.json

With this data:

{
  "title": "bar",
  "path": "/bar"
}

It resolve as mydomain.com/foo/bar, but I want mydomain.com/bar

It's possible?


Post scriptum:
I can't put the json in pages/bar.json because these files (hundreds) are generated by a script.

@KyleAMathews
Copy link
Contributor

Only in markdown frontmatter can you set the path directly. Paths are derived from the filenames by default which is why you're seeing /foo/bar/. You'll want to use the rewritePath API to set the path. This isn't documented atm but you can see an example on my blog https://github.com/KyleAMathews/blog/blob/master/gatsby-node.js#L3

It should be pretty straightforward, just look for a path key on your json files and return that.

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

2 participants