Search code examples
javascriptnode.jsnpmverceldocusaurus

Change base /docs/ path to /home/ | Docusaurus


I am trying to rename the default docs path to home so that all the "documentation" files will be found under the home directory like home/doc1. So, I followed this guide: https://docusaurus.io/docs/docs-multi-instance and changed up my docusaurus.config.js file like so:

module.exports = {
  title: 'Neuro Guide',
  tagline: 'The tagline of my site',
  url: 'https://neuro-guide.vercel.app',
  baseUrl: '/',
  favicon: 'img/favicon.ico',
  organizationName: 'aakhilv', // Usually your GitHub org/user name.
  projectName: 'neuro-guide', // Usually your repo name.
  themeConfig: {
    navbar: {
      title: 'Neuro Guide',
      logo: {
        alt: 'Logo',
        src: 'img/logo.svg',
      },
      links: [{
        to: 'home/doc1',
        activeBasePath: 'home',
        label: 'Home',
        position: 'left',
      }, ],
    },
    footer: {
      style: 'dark',
      copyright: `© ${new Date().getFullYear()} aakhilv`,
    },
  },
  plugins: [
    [
      '@docusaurus/plugin-content-docs',
      {
        id: 'home',
        path: 'home',
        routeBasePath: 'home',
        docs: {
          sidebarPath: require.resolve('./sidebars.js'),
        },
        theme: {
          customCss: require.resolve('./src/css/custom.css'),
        },
      },
    ],
  ],
};

However, I keep getting this error:

Anyone know how I could fix it?


Solution

  • I think the error is because you need at least one theme activated. If you use the classic preset (https://docusaurus.io/docs/presets#docusauruspreset-classic) then you just need to set this config:

    presets: [
      [
        '@docusaurus/preset-classic',
        {
          docs: {
            path: 'home',
            routeBasePath: 'home',
          },
        },
      ],
    ],