Javascript frameworks and libraries have evolved to resolve many of the early problems faced by web apps. They offer a wide arrange of built-in tools and support for SPA’s (Single Page Apps) like decoupling the front-end, building UI’s with stateful components, and working with dynamic data. They also offer the ability to create rich, native-like user experiences via routing with page transitions. The former sounds great for large-scale, complex apps, but what about small-scale, simple apps and static web sites? I’ve heard great things in regards to server side rendering, but what I want to know is: are they a good fit for creating pre-rendered sites for static hosts like Github Pages or Netlify?
Let’s find out…
Objectives Checklist
- Does it offer full control over the final exported markup? In other words, can it be used to generate clean, well-formed, semantic markup will be SEO-friendly, accessible, and performant (using known best practices and techniques)?
- Is it truly pre-rendered or does it require a JS framework to function as a site when hosted? For example, does the exported site only run with a router? …can it easily be moved around within sub-directories with relative paths?
- Does it offer support/alignment for rich-like experiences (e.g. page transitions) when used as a static site generator? For example, if a custom or found page transition system (e.g. a plugin) works when developing locally, will it work when the site is exported and hosted as a static generated pre-rendered site of html files?
- Is it overkill (too much trouble/hassle to setup, configure, etc) for a static site? For example, is a Config file required? …does it require buying into an elaborate, opinionated directory-structure/build-tool/workflow ecosystem?
The Big Three JS Frameworks
- React – https://reactjs.org/ (made by Facebook)
- Vue – https://vuejs.org/
- Angular – https://angular.io/ (made by Google)
Static sites aside, Angular, React, and Vue are the most popular JS frameworks, each offer different advantages over one another. For the purposes of this blog, let’s focus on static site generation, which leads us to the following:
- React >
- Next – https://nextjs.org/
- Gatsby – https://www.gatsbyjs.org/
- React Static (?) – https://react-static.js.org
- Vue >
- Nuxt – https://nuxtjs.org/
- VuePress – https://vuepress.vuejs.org/
- Angular >
- Angular Universal (?) – https://angular.io/guide/universal
List of Static Site Generators (SSG’s)
- Jekyll – https://jekyllrb.com/ (supported on Github Pages)
- 11ty (aka Eleventy) – https://www.11ty.io/
- Gatsby – https://www.gatsbyjs.org/
- Spike – https://spike.js.org/ (by the same people from Carrot Creative that created reshape, comes with a custom webpack setup)
- Hugo – https://gohugo.io/
- Hexo – https://hexo.io/
- Docusaurus – https://docusaurus.io/
- Mkdocs
- Pelican
- Metalsmith
- Middleman
- Gitbook
Learning Notes
After listening to Guillermo Rauch on Episode 354 of the Shop Talk Show I decided to do some hello-world level intro Next tests.
- https://nextjs.org/learn/basics/getting-started
- Learned about the power of the <Link> tag for navigating between pages inside of a pages/ directory (eg. index.js and about.js).
- Learned about Webpack’s hot module replacement
- Learned how shared components can be used for two common use cases:
- as a shared/common/reusable header component that is imported at the top of each page via a component tag <Header />.
- as a Layout, where the content between Layout tags are passed to a shared/common/reusable Layout.js file via props {props.children].
- Learned about creating dynamic pages via a url query string vs. clean urls with route masking.
- Learned how to export out static pages using npm run export via a next.config.js file. NOTE: you had to list out each and every page that you wanted exported to html.
- Looked in Netlify CMS and did some simple tests.
Personal Tests
- NMA Jekyll SSG Test Site with Netlify CMS
- Repo: https://github.com/kccnma/cms
- Github Pages Hosted Site: https://kccnma.github.io/cms/
- Netlify Hosted Site: https://nma.netlify.com/
- NMA Gatsby SSG Test Site with Netlify CMS
- Repo: https://github.com/kccnma/cms-gatsby
- Netlify Hosted Site: https://kcccm.netlify.com/
Resources & Random Stuff:
- SSG Comparison tables and articles comparing SSG’s:
- StaticGen (managed by Netlify)
- Awesome Static Generators
- https://www.netlify.com/blog/2018/08/09/10-static-site-generators-and-popular-uses-for-them-in-2018/#tldr (has an interesting “Great for” use case column)
- Lists from Articles/Blogs:
- Other:
- https://github.com/sdras/intro-to-vue
- https://css-tricks.com/simple-server-side-rendering-routing-page-transitions-nuxt-js/
- https://github.com/turbolinks/turbolinks#making-transformations-idempotent
- https://css-tricks.com/page-transitions-for-everyone/
- https://css-tricks.com/native-like-animations-for-page-transitions-on-the-web/
- https://vuepress.vuejs.org/guide/getting-started.html#global-installation
- https://nuxtjs.org/examples
- https://medium.freecodecamp.org/how-to-generate-a-static-website-with-vue-js-in-no-time-e74e7073b7b8
- https://blog.pusher.com/demystifying-page-transitions-nuxt/
- https://markus.oberlehner.net/blog/vue-router-page-transitions/
- https://vueschool.io/courses/static-site-generation-with-nuxtjs?friend=nuxt
- https://nuxtjs.org/guide#static-generated-pre-rendering-
- https://medium.com/vue-mastery/10-reasons-to-use-nuxt-js-for-your-next-web-application-522397c9366b
- https://hackernoon.com/animated-page-transitions-with-react-router-4-reacttransitiongroup-and-animated-1ca17bd97a1a
- https://css-tricks.com/animating-between-views-in-react/
- https://blog.etch.team/react-page-transitions-make-your-website-feel-native-bf2804b011dc
- https://medium.com/@tannerlinsley/%EF%B8%8F-introducing-react-static-a-progressive-static-site-framework-for-react-3470d2a51ebc
- Gatsby Page Transitions