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

Change src directory to another directory name #2424

Closed
bernatfortet opened this issue Oct 12, 2017 · 17 comments · Fixed by #4490
Closed

Change src directory to another directory name #2424

bernatfortet opened this issue Oct 12, 2017 · 17 comments · Fixed by #4490

Comments

@bernatfortet
Copy link

Hi, I love gatsby!

But I'd love to change the name of the src directory to another name.
I can't figure out exactly how to tell gatsby about this change.

Thanks

@KyleAMathews
Copy link
Contributor

We don't support this atm. What's your use case for wanting to change the name?

@bernatfortet
Copy link
Author

@KyleAMathews It's not a really strong one, it's fine.

I just like using "app". Mostly because it appears at the top of my tree view. Kind of a petty use case...

Thanks any way

@arsdehnel
Copy link
Contributor

My use case I was after when I landed on this issue is around having a gatsby site inside another repo and the gatsby code would be the docs for that site. So something like this:

<project-root>
  - docs (this is where gatsby would live)
  - src (this is where the project code would live)

And then have the publishing setup to use that docs directory instead of src.

@nodox
Copy link
Contributor

nodox commented Nov 8, 2017

REPOST of #2839 : I see that src/pages path plus src/layouts or src/templates are hard coded directories in my project stack. The name src is conflicting with another src folder I have in my project. Therefore I wish there was a way I could designate a custom path for the folder I want gatsby to use for autogenerated pages.

component-page-creator.js is the file I supposed is responsible for this default behavior but when I introduced my change, the app broke. Other files of interest are

load-plugins.js
src/bootstrap/index.js 

The way I thought about introducing the custom path was through the gatsby-config.js because its loaded on bootstrap however it broke the query-watcher.js when I save the file with a change.

What is the best way to introduce this custom path?

@KyleAMathews
Copy link
Contributor

src/templates is just a convention — do you mean src/pages?

If we want to make it possible to auto-create pages elsewhere, we should extract https://github.com/gatsbyjs/gatsby/tree/master/packages/gatsby/src/internal-plugins/component-page-creator to its own package then add a way to disable page creation. Then you could use the extracted package standalone to create pages from another directory.

Want to take that on?

@nodox
Copy link
Contributor

nodox commented Nov 8, 2017

@KyleAMathews I'm happy to give this a try although I will need a good bit of guidance. 😄

@KyleAMathews
Copy link
Contributor

@nodox awesome! Want to create another issue and I'll add some suggestions there?

@bluetidepro
Copy link

I would also love this feature to change the directory name. I have the same use case as @arsdehnel, where I want it to be in like a docs type folder, and my code for the actual project (non-gatsby stuff) is in the src folder. Has this ever been added, or is it still a pending feature?

@m-allanson
Copy link
Contributor

@bluetidepro there's a nearly-complete PR for this over at #4490

@Undistraction
Copy link
Contributor

Undistraction commented Apr 30, 2018

I would love to be able to split my app into code used to build the site (page creation, node manipulation, configuration etc) and code related to rendering the site (components, styles, view helpers, queries etc). This would involve two subdirectories - src/build and src/render. To make this work I would need to to be able to move src/pages and src/layouts into the render directory, however they are hard coded at the moment so this isn't an option.

@bluetidepro
Copy link

@m-allanson Sweeeet. Can't wait for that to get merged!

@nodox
Copy link
Contributor

nodox commented May 3, 2018

Work has been intense. Looking to get back on this sometime within the next 2 weekends. @m-allanson.

@m-allanson
Copy link
Contributor

No worries @nodox! Give yourself some downtime and come back to this whenever you're ready :)

mattiasnordqvist added a commit to mattiasnordqvist/rkmacharya that referenced this issue Jul 25, 2018
@LandonSchropp
Copy link

@m-allanson It looks like this issue was closed in #4490, but I'm having a ton of trouble tracking down how to use it. I didn't see anything in the Gatsby Config documentation, and the PR is a bit difficult to follow. Would it be possible to provide a simple example?

Thanks!

@m-allanson
Copy link
Contributor

Hey @LandonSchropp it's not possible to rename the src directory but you can tell Gatsby to generate pages from a custom directory. e.g. ./my-pages instead of the default ./src/pages. Check out the page creator plugin for more details: https://www.gatsbyjs.org/packages/gatsby-plugin-page-creator/

@LandonSchropp
Copy link

@m-allanson Thanks for the reply!

@neilhem
Copy link

neilhem commented Apr 10, 2019

In case of monorepo having configs to change source code folder would be great

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