This blog is forked from timlrx/tailwind-nextjs-starter-blog with very minor modifications.
Static hosting services / GitHub Pages / S3 / Firebase etc.
-
Add
output: 'export'innext.config.js. See static exports documentation for more information. -
Comment out
headers()fromnext.config.js. -
Add
unoptimized: trueto theimageskey innext.config.js:Alternatively, to continue using
next/image, you can use an alternative image optimization provider such as Imgix, Cloudinary or Akamai. See image optimization documentation for more details. -
Remove
apifolder and components which call the server-side function such as the Newsletter component. Not technically required and the site will build successfully, but the APIs cannot be used as they are server-side functions. -
Run
yarn build. The generated static content is in theoutfolder. -
Deploy the
outfolder to your hosting service of choice or runnpx serve outto view the website locally.
Note: Deploying on Github pages require addition modifications to the base path. Please refer to the FAQ for more information.