Blogging on Next.js: Generating static index pages
javacrisps.com
javacrisps.com
Because sometimes it's fun, and when you're doing it for personal projects it's up to you what route you want to go down. Wordpress or Ghost would be valid choices, too.
I imagine there are people out there who would find it easier to get a Next / React blog setup than to work with Jekyll, because they're familiar with JS and have never heard of or touched Ruby.
I used Jekyll on a couple of project and never had to touch Ruby, but Eleventy is a better option for JS devs.
One of the issues I had with 11ty in the past was that it was hard to get started. At least with gatsby they provide a guided experience with a bunch of community content to get you through.
In general I found it straightforward but I had a couple of headscratching moments and the docs weren't super helpful.
But lately I’ve been using Gatsby/React, first out of curiosity, but now because it’s much quicker for me to develop.
Jekyll’s partials are nice to use but can become hard to read when there are too many variations, or if there are things to be calculated per instance. The Liquid template engine is quite limited.
Also, I absolutely love React’s CSS Modules, which solves the namespacing of Jekyll’s partials.
And in general I find working with React components much easier.
I still use Jekyll for tiny projects [1], but go the Gatsby way for more complex stuff.
And if you want to add more complex behavior, it's easy to transition it on per page basis. i.e. I want to lock some pages (courses) only to GitHub sponsors.
This is a bit 'harder' to do than alternatives like Hugo, Eleventy etc. (in my opinion)
Oh and for blog part, if you want to do some fancy things like mdx, React/Next is nice as there is a template you can use for it https://github.com/hashicorp/next-mdx-enhanced
Otherwise, you'd have to create something of your own.
Using partials is nowhere near as nice as using real components.
I'm working on a Node SSR project and after trying a couple of templating engines I ended up using Svelte components in SSR mode.
How does it handle authentication? Is there a backend somewhere?
If you're ok with editing code files (markdown, html, etc) this is extremely simple to setup. You can even get a template somewhere[1] and just start producing content. Obviously this is only feasible for devs or maybe designers with HTML/CSS skills.
I'd like to add that SSGs can also render dynamic data from an API or directly from a DB at build time.
> no new files are sent from the server
But you can have 'static' with code splitting and send new files from the server on each route change.
The framework's job is to upgrade gracefully - e.g. to facilitate building runtime functionality that meshes well with the statically rendered output.
Next.js and its fellows let you statically render anything you want. It can be a fully static output if you like.
The benefit of building it all out of React components is that there's no integration or binding that has to be done between the "static" elements of the page and the dynamic ones. They're one and the same, the only difference is the first render happens at build time.
A Next.js page that degrades gracefully is just one that's useful even if it only renders once.