-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
docs: guide for porting an html site to gatsby #18609
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really really great content @Jeddf! Thanks so much for working on this and taking on a such a long guide. 🎉
Thanks for making the distinction between guides vs tutorials, this does read like a tutorial in a lot of ways, though I sort of feel like that could be okay in this case given the nature of this content.. 🤔 I'm sure others from @gatsbyjs/learning or Core might chime in with some suggestions.
I gave some ideas for you to consider mostly in linking to additional content and trying to clarify some things.
export default () => <div>Hello world!</div> | ||
``` | ||
|
||
Run the development server in the command line to see the website: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In regards to your comment about this guide resembling a tutorial in some places, perhaps this line is enough, and we could remove the lines below about the gatsby develop command and seeing the site in your browser. Opting to cross reference them in a guide like the Quick Start, so we don't have to duplicate those steps? 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeh I agree, I have a strong urge to keep 'em on the page but this is a good spot to remind them about the rest of the docs that they can move onto after too.
Co-Authored-By: Kyle Gill <kylerobertgill@gmail.com>
Thanks @gillkyle, appreciate that coming from the CRA port master! ⚓️ Yeh I kept looking at spots to link to in the docs but they didn't quite seem to fit with trying to minimize JavaScript and stick to the basic, static application. Definitely think there might be other approaches though, it's an interesting one. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My nitpicks ...
I miss in the further steps section:
|
Co-Authored-By: Michael <184316+muescha@users.noreply.github.com>
Thanks for taking a look @muescha! Those ideas for further steps both sound good, I'll look at adding them in later today 👍. |
Done! They sorta popped out as one section together, think it rounds the guide off nicely, really appreciate the suggestion. Interested to hear your thoughts on it @muescha. I also added a bit about Gatsby handling assets, the next steps section is maybe looking a little heavy now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks great to me.
some fixes and some questions comes up added
└── shrinking.js | ||
``` | ||
|
||
2. The `pathPrefix` configuration option is no longer needed as the Gatsby application will now be served at the root of the site alongside the remaining HTML files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we still need the build with --withPaths
for the assets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aye, there's a note up with the build step on line 479 that I think does the trick in explaining this:
> **Note**: The
--prefix-paths option _must_ be used for path and asset prefixes to be applied
Thinking they'll find themselves back up there when building again if they hit problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a question: what does the asset prefix stuff gain? Could this guide be simplified and include global CSS instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking again at the asset prefix docs page as well, I think it'll follow on from this guide really cleanly for the reader. I'll take a pass through to take out asset-prefix from the example, host the whole gatsby build output at the /who path and move the css, png etc to assets folder on the website-domain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean by global CSS? Directly importing a CSS file in the Layout.js file? I'd lean more toward keeping a basic link tag so the method stays consistent with the remaining HTML pages, so
<link rel="stylesheet" type="text/css" href="https://gatsby-html-partial-assets.s3.eu-west-2.amazonaws.com/style.css" />
becomes
<link rel="stylesheet" type="text/css" href="/assets/style.css"/>
|
||
2. Adjust the `pathPrefix` Gatsby configuration option to reflect the new root path at which the Gatsby application will be served. | ||
|
||
3. Ensure the `to` props on all Gatsby `<Link>` components are correct relative to `/src/pages/` as the application root. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
general question (maybe adressed also early on this page): here we use <Link>
for all pages in the old and new website or only for the new website (preloading is compatible with old html pages?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you adressed this in the next point 3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs warn against using <Link>
for external sites, I took that to mean anything outside the Gatsby app but looking back it may just be external to the website as a whole.
Once pathPrefix
is not being used in a project, I don't know if there is a reason not to use <Link>
for non Gatsby, internal pages. That is a possible small clarification to add to the Link page. Will dig a little to find the answer.
Co-Authored-By: Michael <184316+muescha@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for working on this! I left some suggestions for adjusting the text; please let me know if you have any questions when going through them. Something to keep in mind: I do think this should exist as a Reference Guide rather than a tutorial, even if it is a lot of a how-to. Perhaps some adjustments to headings and text could help the sections stand on their own? That's what would make it more of a guide than a tutorial.
|
||
## Why Gatsby? | ||
|
||
### Web building blocks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the way you're thinking here, but these paragraphs detract from the purpose of a reference guide: to provide reference material for doing the task of porting a site to Gatsby. Perhaps we could summarize this section and link off to a different page on "Why Gatsby"? It is unusual for a reference guide or even a tutorial to have this much background on the page itself. Here's a page we could briefly introduce and link off to instead, which would shorten this quite a bit:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very much agree, I've tried to help the reader focus in the rest of the page but this section would certainly make my mind wander. Pushing up a rewrite shortly, keen to hear your thoughts on it.
└── sam-surgeon.html | ||
``` | ||
|
||
The `/who` section of the site is a great candidate for porting as it is all within a single folder. Through this guide, you will develop the ported Gatsby section in isolation before integrating into the site. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does isolation
refer to here? Can we add something to explain it a bit further, such as "you will develop the ported Gatsby section in isolation before integrating into the site by _____"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, pushing up this addition shortly.
└── shrinking.js | ||
``` | ||
|
||
2. The `pathPrefix` configuration option is no longer needed as the Gatsby application will now be served at the root of the site alongside the remaining HTML files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's a question: what does the asset prefix stuff gain? Could this guide be simplified and include global CSS instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for working on this! I left some suggestions for adjusting the text; please let me know if you have any questions when going through them. Something to keep in mind: I do think this should exist as a Reference Guide rather than a tutorial, even if it is a lot of a how-to. Perhaps some adjustments to headings and text could help the sections stand on their own? That's what would make it more of a guide than a tutorial.
Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com>
Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com>
Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com>
- Briefly explain JSX and add in some mentions. - Expand and clarify JavaScript / JSX passages. Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com>
Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com>
Yeh! Now that the page is about porting HTML in general, tangling it up with path prefix all the way through is possibly confusing. Maybe there are 2 topics here really. Migrating an HTML site to gatsby and nesting a Gatsby app into an HTML site. Can flip it to a complete porting first then talk about the prefix stuff and it'll be easier to link out at that point. I'll extract path prefix as a next iteration. Then take another look at what can be linked out/moved to recipes/other pages. I reckon the change will make lotsa other pages more applicable. |
I've restructured it to be a direct porting from HTML guide 🎉 It feels clearer, I like how it's shaken out. Screenshot is not updated unfortunately. Will take a pass tomorrow over it with the gatsby docs, to see what I think can be linked out/moved to recipes/other pages. |
Looks very good |
Yeh I think enough should be done in the page for a user to be able to locate the prefix instructions at a logical spot and understand the use case. Added a hosting section with enough direction to apply pathPrefix while also linking out to the docs pages for path and asset prefix. What do you think @muescha? I'm a little concerned about having included explicit instructions in the flow for a step that's optional. Hopefully it's made clear enough by having a repeated build bash line though. |
Happy Halloweeeeen @marcysutton! I've addressed your suggestions and made an additional structural change to suit it now not just being a partial porting guide as suggested by @muescha. The core example is now a full HTML site migration, and pathPrefix is offered as an optional step around build and deploy if the site is not to be hosted at the domain root. The opening positions it relative to the main tutorial. Despite it being somewhat similar, I think there is still significant value in providing a shorter, focused path for new users to get from HTML to a Gatsby static site. It could go full reference guide by hedging closer to the format of the CRA porting page and addressing each of the points somewhat in isolation rather than structuring it around an overall example. I think in that case though you'd ask a little more of the reader by having them need to thread together an end to end development flow themselves. I'm assuming the HTML porting user's current build process will likely just be edit file and upload/commit. While the CRA structure suits addressing points likely to be hit when adapting their existing workflow, the HTML user is likely to be starting a development flow from scratch, so structuring around an example and walkthrough makes sense. 🎃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so cool! I think it's going to be very useful to users. I think it's worth tweaking slightly and merging in this format. It's had a lot of work go into it already, and I think it's in great shape. Thank you so much for all of your hard work on this, and let me know if you have any questions!
|
||
If the Gatsby site is to be hosted at a non-root path, e.g. `example.com/blog/`, Gatsby needs to be informed so page and asset links in the built output can be prefixed. | ||
|
||
[Path prefix](/docs/path-prefix/) is the Gatsby option for setting a non-root hosting path. Here is the example project `gatsby-config.js` file with a path prefix added for `/blog`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice! 👍
Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com>
Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com>
#13813 requests some incremental change. This is lost now In the rewriting. Maybe at some point we can stop in the middle (maybe after changing the Maybe to answer the questiin: Can the files from |
That's a good point. @Jeddf I'd recommend addressing it at the beginning of the doc to help the reader establish whether they want to read the whole thing by talking specifically about those two use cases. At the end of the intro paragraph, you could say something like "This doc could also be applied to migrate a section of a site to be served next to existing files; pay extra attention to the section on Hosting..."
That could be addressed in the Building & Deploying section, near where you talk about hosting and the |
Great point, it definitely no longer addressed the original issue. I've used the note format that I've seen in a few other docs to add to the introduction. Almost added a new heading with the extra note for the section porting part, but having it just be part of the hosting section makes it clearer it's optional I think. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one has gone through sufficient rounds of feedback, so we should merge it in (we can always make updates later if needed)! Thanks so much to @Jeddf for your work on this. It's going to be very helpful to users!
Holy buckets, @Jeddf — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
Description
This PR adds a reference guide for porting part of a HTML website to Gatsby.
For context, and possible further use, I've pushed up the whole example site and finished port to a personal repo.
Possible improvements:
This PR places it in the Porting to Gatsby reference guide overview but it feels closer to a tutorial as it strives to stay focused for an audience that has a very particular task in mind and may only have worked with HTML and CSS. Might be better broken up into tutorials or with some parts replaced by links to recipes?
Remove S3 asset links? (I think they're handy for demonstrating the utility of assetPrefix but probably not suitable for inclusion in the guide)
Create a basic starter with Helmet and a basic Layout component already added so we can skip those parts?
Related Issues
Fixes #13813
Preview (in 2 parts 😂) - updated for 02061cc