Nextra 3.0がリリースされました。 詳細はこちら
ドキュメントガイド静的エクスポート

静的エクスポート

ページを静的にエクスポートし、NginxGitHub Pagesなどでデプロイします。

はじめに

設定

next.config.mjs
import nextra from 'nextra'
 
/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  output: 'export',
  images: {
    unoptimized: true // mandatory, otherwise won't export
  }
  // Optional: Change the output directory `out` -> `dist`
  // distDir: "build"
}
const withNextra = nextra({
  theme: 'nextra-theme-docs',
  themeConfig: './theme.config.tsx'
})
 
export default withNextra(nextConfig)

ビルド

パッケージマネージャーに応じてbuildコマンドを実行します

npm run build

デフォルトでは、静的エクスポートはプロジェクトルートのoutディレクトリに保存されます。

静的エクスポートの詳細については、Next.jsのドキュメントを参照してください。