GitHub 维基目录

使用 GitHub 回购安装的 wiki 是否支持目录?我们的维基页面杂乱无章,我们正在寻找一种更好地组织它们的方法。

我们尝试拉回购,创建本地目录,并移动周围的东西,但当提交回来,维基没有采取的变化。

32251 次浏览

I was having the exact same issue and tried variants of what you tried. Nothing stuck. Asked GitHub support about it and received a reply that essentially said "No, but we'll let the developers know that people are interested in this feature."

So the short answer is "No", and the long answer is "No, but maybe in the future."

Actually, it looks like github added support for directories recently.

I was able to do the following:

  • Move an existing markdown file to a new directory.
  • Create a new markdown file in an existing directory (created in the former step).
  • Create a new markdown file in a new directory.

In all cases, the existing pages were still there and new pages were added.

The one constraint that remains is that your file names must be unique. If you have more than one file with the same name, only one of them will show up in the wiki (I'm not sure which.. ).

The GitHub wiki (aka Gollum) does use directories but not in the way you may expect.

The documentation on the Gollum wiki could use some work but this is what I have figured out mostly via testing.

  • All files appear in the root of the wiki no matter where they are placed in the repo.
  • _Header, _Footer and _Sidebar files are per-directory, but inherited if there is none present in a child folder.
  • File links can be relative to the source file (keep your files with your content).

So, if you want directories for namespacing you are out of luck. Consider using the {namespace}-{page} scheme for namespacing.

Actually, there is still a limitation. Yes, you can add 1 level (so, 1 subfolder). But that's it! I refactored my whole documentation layout, creating multiple levels of subfolders for organisation, but that was a no-go.

sigh

I must say: I'm appalled by this Gollum thing. I'm surprised Github even picked it up.

It's not the an ideal solution but the workaround would be to create a custom sidebar where you create a table of contents with links to your pages. I find this to be better than folders anyway because it allows you to have a link to a single page under multiple hierarchies.

Well, that's a disappointing missing feature! What I try to do is to actually have directories under a docs directory and in each one, a README.md file. Not great...but works for documentation and organizes stuff. If you want to go further, you can have a different branch only with these files.

Still no intention of adding this 9/2022.

https://github.com/orgs/community/discussions/23914