简体   繁体   中英

Docusaurus - Hide always folder's name in url

this is my question about docusuarus (docusaurus.io):

In my site I have several folders inside "docs" folder:

docs
    doc1.md
    folder1
        doc2.md
    folder2
        doc3.md

so when I call a document, for example, "doc2.md", in the url i see:

domain.com/folder1/doc2

I would like to hide the folder name in all cases:

domain.com/doc1
domain.com/doc2
domain.com/doc3

Is it possible to do this? Thanks.

I'm not sure about this but give a try please.

You can declare that you want this behavior in docusaurus.config.js file like this:

module.exports = {
  // ...
  docs: {
    path: 'docs',
    pages: [
      {
        path: 'file2',
        route: '/file2',
        title: 'File 2',
        sidebar_label: 'File 2',
        source: 'folder1/file2.md',
      },
    ],
  },
  // ...
}

now try navigating to it like this: exampleSite.com/file2 , with remaining your folders structure.

Thanks for response Gwhyyy.

I found an easy solution:

We can add a slug option at the top of each file, example:

---
id: File2
title: File 2
slug: /file2
---

Regards.

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