Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(v2): clarify instructions on docs-only mode #2395

Merged
merged 2 commits into from
Mar 10, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 34 additions & 10 deletions website/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,27 +150,51 @@ If you just want to use those fields on the client side, you could create your o

## Docs-only mode

You can run your Docusaurus 2 site without a landing page and instead have a page from your documentation as the index page.
While Docusaurus 2 is a performant static site generator with support for blogs, product landing and marketing pages, some sites just want the documentation component.

Set the `routeBasePath` to indicate that it’s the root path.
There are some steps you need to follow for a ”docs-only mode“:

**Note**: Make sure there’s no `index.js` page in `src/pages` or there will be two files mapped to the same route!
1. Set the `routeBasePath` property of the `docs` object in `@docusaurus/preset-classic` in `docusaurus.config.js` to the root of your site:

```js {9}
```js {11}
// docusaurus.config.js
module.exports = {

// ...

presets: [
[
'@docusaurus/preset-classic',
{
docs: {
routeBasePath: '/' // Set this value to '/'.
},
},
],
],
routeBasePath: '/'
}
}
]
]

// ...
};
```

You can apply the same principle for blogs with the [Blog-only mode](blog.md#blog-only-mode).
2. Set up a redirect to the initial document on the home page in `src/pages/index.js`, e.g. for the document `getting-started`:

```jsx
import React from "react";

import { Redirect } from "@docusaurus/router";

function Home() {
return <Redirect to="/getting-started" />;
}

export default Home;
```

Now, when visiting your site, it will show your initial document instead of a landing page.

:::tip

There’s also a ”blog-only mode“, for those who only want to use the blog component of Docusaurus 2. You can use the same method detailed above, except that you need to delete the `src/pages/index.js` file. Follow the setup instructions on [Blog-only mode](blog.md#blog-only-mode).

:::