[英]Docusaurus - Hide always folder's name in url
this is my question about docusuarus (docusaurus.io):这是我关于 docusuarus (docusaurus.io) 的问题:
In my site I have several folders inside "docs" folder:在我的站点中,“docs”文件夹中有几个文件夹:
docs
doc1.md
folder1
doc2.md
folder2
doc3.md
so when I call a document, for example, "doc2.md", in the url i see:因此,当我在 url 中调用文档(例如“doc2.md”)时,我看到:
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:您可以在
docusaurus.config.js
文件中声明您想要此行为,如下所示:
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.现在尝试像这样导航到它:
exampleSite.com/file2
,保留您的文件夹结构。
Thanks for response Gwhyyy.感谢您的回复 Gwhyyy。
I found an easy solution:我找到了一个简单的解决方案:
We can add a slug option at the top of each file, example:我们可以在每个文件的顶部添加一个 slug 选项,例如:
---
id: File2
title: File 2
slug: /file2
---
Regards.问候。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.