简体   繁体   中英

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?

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',
      },
    },
  ],
],

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM