One nice feature of Next.js is that it can both be used for Server-Side Rendering (SSR) and Static Site Generation (SSG), Pipit uses SSR by default, but also supports SSG. This guide will show you how.
Make sure you read through our Getting started guide and have everything installed.
Open the frontend directory
cd frontend
Now proceed to disable SSR functions and enable SSG functions
-
In
frontend/pages/[...path].js
, comment outgetServerSideProps
and un-commentgetStaticProps
andgetStaticPaths
-
In
frontend/pages/_preview
, uncommentgetStaticProps
and comment outgetServerSideProps
-
In
frontend/pages/index.js
, uncomment the line below// For SSG
and comment out the line after// For SSR
-
Open
next.config.js
and add/changeoutput
to export.const nextConfig = { output: 'export', ... }
After that, create a html export.
npm run build
This will create a folder called /frontend/out
that will contain your website exported as static html files.
Continue by opening the dir and run a webserver as its root
cd out
python3 -m http.server 8000
Finally open http://localhost:8000 in your favorite browser and you should see your website.