How to make the home page layout like a sidebar + docs page? #4373
-
For our internal docs, we are using the default theme, but we don't need a splashy home page, and would instead like to make the home page behave like a docs page. We know we can remove the frontmatter and have it display like
I've tried mucking about with custom styles, but there's a lot to be considered, especially with breakpoints, etc. I also tried rewrites (to skip the home page and jump directly to a section) but I think I need to those on the server level, and this is just internal. Does anyone know how we can make the home page behave more consistently? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
What does your sidebar config look like? I’m doing this at my company — https://sefirot.globalbrains.com/ — we just have a index.md in docs without home layout — https://github.com/globalbrain/sefirot/tree/main/docs |
Beta Was this translation helpful? Give feedback.
-
Ah, I'm running the "multiple sidebars" setup with a navigation bar. Home page: Section page: Config: import { defineConfig } from 'vitepress'
import { withSidebar } from 'vitepress-sidebar'
// -----------------------------------------------------------------------------
// helpers
// -----------------------------------------------------------------------------
// @see https://vitepress-sidebar.cdget.com
function getMenu(folder) {
return {
documentRootPath: `docs`,
scanStartPath: folder,
basePath: `/${folder}/`,
resolvePath: `/${folder}/`,
useTitleFromFileHeading: true,
useFolderTitleFromIndexFile: true,
capitalizeEachWords: true,
includeFolderIndexFile: true,
}
}
...
export default withSidebar(config, [
getMenu('setup'),
getMenu('backend'),
getMenu('frontend'),
getMenu('specs'),
]) |
Beta Was this translation helpful? Give feedback.
OK, this is now the final solution...
I used a
null
in the sidebar config, which is cleaner:And I kept the router "hack" as it just means the logic to hide the sidebar is in one place (as above).
The router hook is now:
The CSS is now: