"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["14096"],{44172:function(e,n,t){t.r(n),t.d(n,{metadata:()=>r,contentTitle:()=>c,default:()=>p,assets:()=>u,toc:()=>d,frontMatter:()=>l});var r=JSON.parse('{"id":"guides/docs/multi-instance","title":"Docs Multi-instance","description":"Use multiple docs plugin instances on a single Docusaurus site.","source":"@site/docs/guides/docs/docs-multi-instance.mdx","sourceDirName":"guides/docs","slug":"/docs-multi-instance","permalink":"/docs/docs-multi-instance","draft":false,"unlisted":false,"editUrl":"https://github.com/facebook/docusaurus/edit/main/website/docs/guides/docs/docs-multi-instance.mdx","tags":[],"version":"current","lastUpdatedBy":"moonrailgun","lastUpdatedAt":1729270082000,"frontMatter":{"id":"multi-instance","description":"Use multiple docs plugin instances on a single Docusaurus site.","slug":"/docs-multi-instance"},"sidebar":"docs","previous":{"title":"Versioning","permalink":"/docs/versioning"},"next":{"title":"Blog","permalink":"/docs/blog"}}'),s=t("24246"),i=t("80980"),o=t("15398"),a=t("58636");let l={id:"multi-instance",description:"Use multiple docs plugin instances on a single Docusaurus site.",slug:"/docs-multi-instance"},c="Docs Multi-instance",u={},d=[{value:"Use-cases",id:"use-cases",level:2},{value:"Mobile SDKs documentation",id:"mobile-sdks-documentation",level:3},{value:"Versioned and unversioned doc",id:"versioned-and-unversioned-doc",level:3},{value:"Setup",id:"setup",level:2},{value:"Versioned paths",id:"versioned-paths",level:2},{value:"Tagging new versions",id:"tagging-new-versions",level:2},{value:"Docs navbar items",id:"docs-navbar-items",level:2}];function h(e){let n={a:"a",admonition:"admonition",code:"code",h1:"h1",h2:"h2",h3:"h3",header:"header",li:"li",p:"p",pre:"pre",ul:"ul",...(0,i.a)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.header,{children:(0,s.jsx)(n.h1,{id:"docs-multi-instance",children:"Docs Multi-instance"})}),"\n",(0,s.jsxs)(n.p,{children:["The ",(0,s.jsx)(n.code,{children:"@docusaurus/plugin-content-docs"})," plugin can support ",(0,s.jsx)(n.a,{href:"/docs/using-plugins#multi-instance-plugins-and-plugin-ids",children:"multi-instance"}),"."]}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["This feature is only useful for ",(0,s.jsx)(n.a,{href:"/docs/versioning",children:"versioned documentation"}),". It is recommended to be familiar with docs versioning before reading this page. If you just want ",(0,s.jsx)(n.a,{href:"/docs/sidebar/multiple-sidebars",children:"multiple sidebars"}),", you can do so within one plugin."]})}),"\n",(0,s.jsx)(n.h2,{id:"use-cases",children:"Use-cases"}),"\n",(0,s.jsx)(n.p,{children:"Sometimes you want a Docusaurus site to host 2 distinct sets of documentation (or more)."}),"\n",(0,s.jsx)(n.p,{children:"These documentations may even have different versioning/release lifecycles."}),"\n",(0,s.jsx)(n.h3,{id:"mobile-sdks-documentation",children:"Mobile SDKs documentation"}),"\n",(0,s.jsx)(n.p,{children:"If you build a cross-platform mobile SDK, you may have 2 documentations:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["Android SDK documentation (",(0,s.jsx)(n.code,{children:"v1.0"}),", ",(0,s.jsx)(n.code,{children:"v1.1"}),")"]}),"\n",(0,s.jsxs)(n.li,{children:["iOS SDK documentation (",(0,s.jsx)(n.code,{children:"v1.0"}),", ",(0,s.jsx)(n.code,{children:"v2.0"}),")"]}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"In this case, you can use a distinct docs plugin instance per mobile SDK documentation."}),"\n",(0,s.jsxs)(n.admonition,{type:"warning",children:[(0,s.jsx)(n.p,{children:"If each documentation instance is very large, you should rather create 2 distinct Docusaurus sites."}),(0,s.jsx)(n.p,{children:"If someone edits the iOS documentation, is it really useful to rebuild everything, including the whole Android documentation that did not change?"})]}),"\n",(0,s.jsx)(n.h3,{id:"versioned-and-unversioned-doc",children:"Versioned and unversioned doc"}),"\n",(0,s.jsx)(n.p,{children:'Sometimes, you want some documents to be versioned, while other documents are more "global", and it feels useless to version them.'}),"\n",(0,s.jsx)(n.p,{children:"We use this pattern on the Docusaurus website itself:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:["The ",(0,s.jsx)(n.a,{href:"/docs",children:"/docs/*"})," section is versioned"]}),"\n",(0,s.jsxs)(n.li,{children:["The ",(0,s.jsx)(n.a,{href:"/community/support",children:"/community/*"})," section is unversioned"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"setup",children:"Setup"}),"\n",(0,s.jsx)(n.p,{children:"Suppose you have 2 documentations:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:"Product: some versioned doc about your product"}),"\n",(0,s.jsx)(n.li,{children:"Community: some unversioned doc about the community around your product"}),"\n"]}),"\n",(0,s.jsx)(n.p,{children:"In this case, you should use the same plugin twice in your site configuration."}),"\n",(0,s.jsx)(n.admonition,{type:"warning",children:(0,s.jsxs)(n.p,{children:[(0,s.jsx)(n.code,{children:"@docusaurus/preset-classic"})," already includes a docs plugin instance for you!"]})}),"\n",(0,s.jsx)(n.p,{children:"When using the preset:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-js",metastring:'title="docusaurus.config.js"',children:"export default {\n presets: [\n [\n '@docusaurus/preset-classic',\n {\n docs: {\n // highlight-start\n // id: 'product', // omitted => default instance\n // highlight-end\n path: 'product',\n routeBasePath: 'product',\n sidebarPath: './sidebarsProduct.js',\n // ... other options\n },\n },\n ],\n ],\n plugins: [\n [\n '@docusaurus/plugin-content-docs',\n {\n // highlight-start\n id: 'community',\n // highlight-end\n path: 'community',\n routeBasePath: 'community',\n sidebarPath: './sidebarsCommunity.js',\n // ... other options\n },\n ],\n ],\n};\n"})}),"\n",(0,s.jsx)(n.p,{children:"When not using the preset:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-js",metastring:'title="docusaurus.config.js"',children:"export default {\n plugins: [\n [\n '@docusaurus/plugin-content-docs',\n {\n // highlight-start\n // id: 'product', // omitted => default instance\n // highlight-end\n path: 'product',\n routeBasePath: 'product',\n sidebarPath: './sidebarsProduct.js',\n // ... other options\n },\n ],\n [\n '@docusaurus/plugin-content-docs',\n {\n // highlight-start\n id: 'community',\n // highlight-end\n path: 'community',\n routeBasePath: 'community',\n sidebarPath: './sidebarsCommunity.js',\n // ... other options\n },\n ],\n ],\n};\n"})}),"\n",(0,s.jsxs)(n.p,{children:["Don't forget to assign a unique ",(0,s.jsx)(n.code,{children:"id"})," attribute to plugin instances."]}),"\n",(0,s.jsx)(n.admonition,{type:"note",children:(0,s.jsxs)(n.p,{children:["We consider that the ",(0,s.jsx)(n.code,{children:"product"}),' instance is the most important one, and make it the "default" instance by not assigning any ID.']})}),"\n",(0,s.jsx)(n.h2,{id:"versioned-paths",children:"Versioned paths"}),"\n",(0,s.jsx)(n.p,{children:"Each plugin instance will store versioned docs in a distinct folder."}),"\n",(0,s.jsx)(n.p,{children:"The default plugin instance will use these paths:"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"website/versions.json"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"website/versioned_docs"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"website/versioned_sidebars"})}),"\n"]}),"\n",(0,s.jsxs)(n.p,{children:["The other plugin instances (with an ",(0,s.jsx)(n.code,{children:"id"})," attribute) will use these paths:"]}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"website/[pluginId]_versions.json"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"website/[pluginId]_versioned_docs"})}),"\n",(0,s.jsx)(n.li,{children:(0,s.jsx)(n.code,{children:"website/[pluginId]_versioned_sidebars"})}),"\n"]}),"\n",(0,s.jsxs)(n.admonition,{type:"tip",children:[(0,s.jsxs)(n.p,{children:["You can omit the ",(0,s.jsx)(n.code,{children:"id"})," attribute (defaults to ",(0,s.jsx)(n.code,{children:"default"}),") for one of the docs plugin instances."]}),(0,s.jsx)(n.p,{children:"The instance paths will be simpler, and retro-compatible with a single-instance setup."})]}),"\n",(0,s.jsx)(n.h2,{id:"tagging-new-versions",children:"Tagging new versions"}),"\n",(0,s.jsx)(n.p,{children:"Each plugin instance will have its own CLI command to tag a new version. They will be displayed if you run:"}),"\n",(0,s.jsxs)(o.Z,{groupId:"npm2yarn",children:[(0,s.jsx)(a.Z,{value:"npm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"npm run docusaurus -- --help\n"})})}),(0,s.jsx)(a.Z,{value:"yarn",label:"Yarn",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"yarn docusaurus --help\n"})})}),(0,s.jsx)(a.Z,{value:"pnpm",label:"pnpm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"pnpm run docusaurus --help\n"})})})]}),"\n",(0,s.jsx)(n.p,{children:"To version the product/default docs plugin instance:"}),"\n",(0,s.jsxs)(o.Z,{groupId:"npm2yarn",children:[(0,s.jsx)(a.Z,{value:"npm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"npm run docusaurus docs:version 1.0.0\n"})})}),(0,s.jsx)(a.Z,{value:"yarn",label:"Yarn",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"yarn docusaurus docs:version 1.0.0\n"})})}),(0,s.jsx)(a.Z,{value:"pnpm",label:"pnpm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"pnpm run docusaurus docs:version 1.0.0\n"})})})]}),"\n",(0,s.jsx)(n.p,{children:"To version the non-default/community docs plugin instance:"}),"\n",(0,s.jsxs)(o.Z,{groupId:"npm2yarn",children:[(0,s.jsx)(a.Z,{value:"npm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"npm run docusaurus docs:version:community 1.0.0\n"})})}),(0,s.jsx)(a.Z,{value:"yarn",label:"Yarn",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"yarn docusaurus docs:version:community 1.0.0\n"})})}),(0,s.jsx)(a.Z,{value:"pnpm",label:"pnpm",children:(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"pnpm run docusaurus docs:version:community 1.0.0\n"})})})]}),"\n",(0,s.jsx)(n.h2,{id:"docs-navbar-items",children:"Docs navbar items"}),"\n",(0,s.jsxs)(n.p,{children:["Each docs-related ",(0,s.jsx)(n.a,{href:"/docs/api/themes/configuration#navbar",children:"theme navbar items"})," take an optional ",(0,s.jsx)(n.code,{children:"docsPluginId"})," attribute."]}),"\n",(0,s.jsx)(n.p,{children:"For example, if you want to have one version dropdown for each mobile SDK (iOS and Android), you could do:"}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-js",metastring:'title="docusaurus.config.js"',children:"export default {\n themeConfig: {\n navbar: {\n items: [\n {\n type: 'docsVersionDropdown',\n // highlight-start\n docsPluginId: 'ios',\n // highlight-end\n },\n {\n type: 'docsVersionDropdown',\n // highlight-start\n docsPluginId: 'android',\n // highlight-end\n },\n ],\n },\n },\n};\n"})})]})}function p(e={}){let{wrapper:n}={...(0,i.a)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(h,{...e})}):h(e)}},58636:function(e,n,t){t.d(n,{Z:()=>o});var r=t("24246");t("27378");var s=t("90496");let i="tabItem_pnkT";function o(e){var n=e.children,t=e.hidden,o=e.className;return(0,r.jsx)("div",{role:"tabpanel",className:(0,s.Z)(i,o),hidden:t,children:n})}},15398:function(e,n,t){t.d(n,{Z:()=>S});var r=t("24246"),s=t("27378"),i=t("90496"),o=t("54947"),a=t("3620"),l=t("844"),c=t("97486"),u=t("32263"),d=t("16971");function h(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=Array(n);t child <".concat("string"==typeof e.type?e.type:e.type.name,'>: all children of the component should be , and every should have a unique "value" prop.'))}))||void 0===n?void 0:n.filter(Boolean))&&void 0!==t?t:[]}function f(e){var n=e.value;return e.tabValues.some(function(e){return e.value===n})}var g=t("71607");let b="tabList_Qoir",v="tabItem_AQgk";function j(e){for(var n=1;n0)throw Error('Docusaurus error: Duplicate values "'.concat(n.map(function(e){return e.value}).join(", "),'" found in . Every value needs to be unique.'))}(e),e},[t,r])),k=p((0,s.useState)(function(){return function(e){var n,t=e.defaultValue,r=e.tabValues;if(0===r.length)throw Error("Docusaurus error: the component requires at least one children component");if(t){if(!f({value:t,tabValues:r}))throw Error('Docusaurus error: The has a defaultValue "'.concat(t,'" but none of its children has the corresponding value. Available values are: ').concat(r.map(function(e){return e.value}).join(", "),". If you intend to show no default tab, use defaultValue={null} instead."));return t}var s=null!==(n=r.find(function(e){return e.default}))&&void 0!==n?n:r[0];if(!s)throw Error("Unexpected error: 0 tabValues");return s.value}({defaultValue:S,tabValues:I})}),2),T=k[0],V=k[1];var N=p((o=(i={queryString:void 0!==P&&P,groupId:D}).queryString,h=i.groupId,g=(0,a.k6)(),b=function(e){var n=e.queryString,t=void 0!==n&&n,r=e.groupId;if("string"==typeof t)return t;if(!1===t)return null;if(!0===t&&!r)throw Error('Docusaurus error: The component groupId prop is required if queryString=true, because this value is used as the search param name. You can also provide an explicit value such as queryString="my-search-param".');return null!=r?r:null}({queryString:void 0!==o&&o,groupId:h}),[(0,c._X)(b),(0,s.useCallback)(function(e){if(!!b){var n,t,r=new URLSearchParams(g.location.search);r.set(b,e),g.replace((n=function(e){for(var n=1;n