react-webpack-generators / generator-react-webpack

Yeoman generator for ReactJS and Webpack
http://newtriks.com/2013/12/31/automating-react-with-yeoman-and-grunt/
MIT License
2.88k stars 355 forks source link

Static pages (SEO related) #286

Closed ZigaVukcevicDev closed 7 years ago

ZigaVukcevicDev commented 7 years ago

Hi,

this is more of a question than an issue.

I was wondering, how could I accomplish that some of pages would be static and seen by web crawlers?

Should I concern server side rendering?

sthzg commented 7 years ago

Hi @be-codified, there are two approaches:

The first is generating static pages from your project. Take a look at Gatsby or Phenomic for inspiration (or even better, ready-to-go solutions). A bit lower-level are packages like static-site-generator-webpack-plugin, which is used by Gatsby and can be configured to work with this generator (no docs/example for that so far).

The second approach is using a server framework (commonly Express or Koa from the NodeJS world) to pre-render the content on the server. Good keywords to search for this are 'ssr with react' or something along the line of universal or isomorphic react apps.

From this generator's side we are currently working on docs/demo branches/template updates to provide easier update and integration paths towards various SSR scenarios, but the code (at least from my side) is too early to be shared. Personally I hope that we have more information on that in a few weeks from now.

/cc @weblogixx

ZigaVukcevicDev commented 7 years ago

Hi @sthzg, thank you very much for your effort.

Looking forward into future solutions.

ZigaVukcevicDev commented 7 years ago

@sthzg I have looked at static-site-generator-webpack-plugin and it suits my needs. I tried to include it in webpack's config but I find it too difficult to this on my own - as I am getting unknown errors to me.

Could you help me with this? This way we could have the proper example how to implement it into your generator, I can write this down as a document, if you wish.

sthzg commented 7 years ago

@be-codified sorry for the late reply, I wanted to answer sooner but haven't been able to find the time. I will see what I can do to put up an example branch, however I don't think it will be available too soon.

ZigaVukcevicDev commented 7 years ago

@sthzg meanwhile, I tried with some other solutions.

sthzg commented 7 years ago

👍 awesome, then there is no hurry. I remember setting it up once (using the V4 gen with the V2 template) and I had to toss quite a bit of config back then, including updating it to creating html from ejs templates. On a separate branch we are currently discussing updating the template behind the generator to the html-webpack-plugin, which from what I read in their issue queue seems to have problems when combining with the static-site-generator-plugin. So depending on what happens in that html-webpack-plugin branch an example on this generator would have to take that into account. Unfortunately that needs a bit more of time and dedication than I have available at the moment, but I hope being able to tackle it next month or so.