Get Started
💡
An example of the blog theme can be found here.
Similar to the docs theme, you can install the blog theme with the following commands:
Configurations
-
Install Next.js, Nextra and React:
yarn add next nextra react react-dom
-
Install the blog theme:
yarn add nextra-theme-blog
-
Create the following Next.js config and theme config under the root directory:
next.config.js
const withNextra = require('nextra')({
theme: 'nextra-theme-blog',
themeConfig: './theme.config.jsx'
// optional: add `unstable_staticImage: true` to enable Nextra's auto image import
})
module.exports = withNextra()
theme.config.jsx
export default {
footer: <p>MIT 2022 © Nextra.</p>,
head: ({ title, meta }) => (
<>
{meta.description && (
<meta name="description" content={meta.description} />
)}
{meta.tag && <meta name="keywords" content={meta.tag} />}
{meta.author && <meta name="author" content={meta.author} />}
</>
),
readMore: 'Read More →',
titleSuffix: null,
postFooter: null,
cusdis: {
appId: 'your_app_id',
host: 'your_host(optional)',
lang: 'your_lang'
},
darkMode: false,
navs: [
{
url: 'https://github.com/shuding/nextra',
name: 'Nextra'
}
]
}
- Create
pages/_app.jsx
and include the theme stylesheet:
_app.jsx
import 'nextra-theme-blog/style.css'
export default function Nextra({ Component, pageProps }) {
return <Component {...pageProps} />
}
- You are good to go!
💡
You can also use <style jsx>
to style elements inside theme.config.jsx
.