Docusaurus: Cannot link directly to doc in sidebar

Created on 14 Nov 2019  路  6Comments  路  Source: facebook/docusaurus

馃悰Cannot link directly to doc in sidebar

I am trying to link to a doc directly in the sidebar per the v2 documentation.

To Reproduce

(Write your steps here:)

  1. Add doc link in sidebars.js code
module.exports = {
  docs: [
    {
      type: "category",
      label: "Get Started",
      items: ["get_started"]
    },
    { 
     type: "doc",
     id: "api"
    }
  ]
};
  1. Run npm run start

Expected behavior

No compile errors, we see the link directly to the doc in the sidebar.

Actual Behavior

It will not compile, see this error in console:

Error: Unknown sidebar item keys: id. Item: {"type":"doc","id":"api"}

bug needs triage

Most helpful comment

All 6 comments

You can't do that.

First level of a sidebar name docs must be category

// sidebars.js
module.exports = {
  docs: [
    {
      type: 'category',
      label: 'Getting Started',
      items: ['greeting'],
    },
    {
      type: 'category',
      label: 'Docusaurus',
      items: ['doc1'],
    },
  ],
};

We should update the docs or at least do better in the error handling i guess

Oh OK, thanks for clarifying!

Thank you. We'll warn it to user better in #1994

Appreciate the quick follow up 馃帀

I actually disagree with this behavior. Why can't a category be a page? A side effect of this is that parent URLs don't work. Ex: /docs/category/child, the URL /docs/category returns a 404.

Related general URL issues: https://github.com/facebook/docusaurus/issues/1941 and https://github.com/facebook/docusaurus/issues/1973

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JoelMarcey picture JoelMarcey  路  3Comments

sebqq picture sebqq  路  3Comments

microbouji picture microbouji  路  3Comments

ericnakagawa picture ericnakagawa  路  3Comments

itelofilho picture itelofilho  路  3Comments