Creating Pages
In this section, we will learn about creating pages in Docusaurus.
The @docusaurus/plugin-content-pages
plugin empowers you to create one-off standalone pages like a showcase page, playground page, or support page. You can use React components, or Markdown.
Pages do not have sidebars, only docs do.
Check the Pages Plugin API Reference documentation for an exhaustive list of options.
Add a React page
React is used as the UI library to create pages. Every page component should export a React component, and you can leverage the expressiveness of React to build rich and interactive content.
Create a file /src/pages/helloReact.js
:
import React from 'react';
import Layout from '@theme/Layout';
export default function Hello() {
return (
<Layout title="Hello" description="Hello React Page">
<div
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
height: '50vh',
fontSize: '20px',
}}>
<p>
Edit <code>pages/helloReact.js</code> and save to reload.
</p>
</div>
</Layout>
);
}
Once you save the file, the development server will automatically reload the changes. Now open http://localhost:3000/helloReact
and you will see the new page you just created.
Each page doesn't come with any styling. You will need to import the Layout
component from @theme/Layout
and wrap your contents within that component if you want the navbar and/or footer to appear.
You can also create TypeScript pages with the .tsx
extension (helloReact.tsx
).