{"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"partial-tag","__idx":0},"children":["Partial Tag ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/learn/markdoc/tags/tag-library#redocly-tag-badge"},"children":[{"$$mdtype":"Tag","name":"TagBadge","attributes":{"badgeType":"Built-in"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The partial tag enables you to reuse content across your documentation, bringing the concept of ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://en.wikipedia.org/wiki/Single-source_publishing"},"children":["single-source publishing"]}," to your technical writing."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"syntax-and-usage","__idx":1},"children":["Syntax and usage"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the partial tag to render content pulled from a file in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["_partials"]}," folder. The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["file"]}," attribute is used to pass a pointer to the source file."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Example syntax:"]},{"$$mdtype":"Tag","name":"MarkdocExample","attributes":{"renderDemo":false,"title":"/docs/setup.md","language":"markdoc","demoContent":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"setup-steps"},"children":["Setup steps"]}],"rawContent":"## Setup steps\n\n{% partial file=\"/_partials/tutorial-first-steps.md\" /%}\n"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"partials-in-redocly","__idx":2},"children":["Partials in Redocly"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The information in this section applies specifically to using partials in a ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Redocly project"]},"."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"use-partial-folders","__idx":3},"children":["Use partial folders"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In Redocly, content is only exposed for reuse when a file is stored in a ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["designated partials folder"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["By default, you can add partials by moving files into a ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["_partials"]}," folder in the root of your project. To add custom folders for partials, you'll need to register them using the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["partialFolders"]}," property in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["markdown"]}," section of your Redocly configuration file."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"limitations-of-partials","__idx":4},"children":["Limitations of partials"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Reference links"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can't use ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://www.markdownguide.org/basic-syntax/#reference-style-links"},"children":["reference-style Markdown links"]}," inside the partial because they resolve incorrectly upon page load. If you're using links inside a partial, then absolute links are the best approach."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"attributes","__idx":5},"children":["Attributes"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Option"},"children":["Option"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["file"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["String"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["The relative or absolute path to the source file used as a partial. Must be stored in a ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"#partials-in-redocly"},"children":["partials folder"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["variables"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Object"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Key value pairs that can be accessed from inside the partial. Useful for conditional rendering and dynamic content."]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"examples","__idx":6},"children":["Examples"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"general-partial-example","__idx":7},"children":["General partial example"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following example shows how to use partials to add a Learning Resources section that can be shared across different guides or tutorials."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example partial content:"]}]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"markdown","data-title":"/_partials/redocly-cli-resources.md ","header":{"title":"/_partials/redocly-cli-resources.md ","controls":{"copy":{}}},"source":"#### Redocly CLI Learning Resources\n\nThe following resources will help you learn more about the Redocly CLI:\n\n* [Redocly CLI commands](/docs/cli/commands) - Learn the commands built into the CLI.\n* [Configure API linting](/docs/cli/guides/configure-rules) - Learn how to tailor the Redocly CLI linting for your own needs.\n* [Redocly CLI cookbook](https://github.com/Redocly/redocly-cli-cookbook) - Bite-sized example CLI customizations to inspire your own.\n","lang":"markdown"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example partial syntax:"]}]},{"$$mdtype":"Tag","name":"MarkdocExample","attributes":{"renderDemo":false,"language":"markdoc","demoContent":[],"rawContent":"{% partial file=\"/_partials/redocly-cli-resources.md\" /%}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example partial elements:"]}]},{"$$mdtype":"Tag","name":"GroupElements","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":4,"id":"redocly-cli-learning-resources","__idx":8},"children":["Redocly CLI Learning Resources"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use the following resources to learn more about the Redocly CLI:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/docs/cli/commands"},"children":["Redocly CLI commands"]}," - Discover new CLI commands."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/docs/cli/guides/configure-rules"},"children":["Configure API linting"]}," - Tailor the CLI's linting for your own needs."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"Link","attributes":{"href":"https://github.com/Redocly/redocly-cli-cookbook"},"children":["Redocly CLI cookbook"]}," - Bite-sized example CLI customizations to inspire your own."]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"partial-with-variables","__idx":9},"children":["Partial with variables"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The following example shows how to use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["variables"]}," to pass values to a partial:"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example partial content:"]}]},{"$$mdtype":"Tag","name":"MarkdocExample","attributes":{"renderDemo":false,"language":"markdoc","demoContent":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[null,"'s favorite food is ",null,"."]}],"rawContent":"{% $person %}'s favorite food is {% $favFood %}.\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example partial syntax:"]}]},{"$$mdtype":"Tag","name":"MarkdocExample","attributes":{"renderDemo":false,"language":"markdoc","demoContent":[],"rawContent":"{% partial\n  file=\"/_partials/favorite-food.md\"\n  variables={\n    person: \"Taylor\",\n    favFood: \"Katsu curry\"\n  }\n/%}\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Example partial elements:"]}]},{"$$mdtype":"Tag","name":"GroupElements","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Taylor","'s favorite food is ","Katsu curry","."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"best-practices","__idx":10},"children":["Best practices"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Partials are especially useful for repeatable content where you want to maintain a central source of truth. Partials add value by improving writer productivity, ensuring information consistency, or reducing maintenance costs."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Descriptive filenames"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Giving your partial a descriptive filename helps the author using it understand what to find there."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Make partials composable"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["All partials ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["render as a whole"]},", meaning all content inside the source file renders. You want content to be self-contained enough that it can be used throughout other documents without additional context needed."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Use code-snippet for code partials"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If a partial contains only code, then the ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/learn/markdoc/tags/code-snippet"},"children":["code snippet tag"]}," may be a better choice. The code snippet tag allows you to insert specific parts of a code sample, which provides more flexibility."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Favor absolute links over relative"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Using absolute links in your partials will ensure that they resolve correctly everywhere that the content is reused."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Nest with caution"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Partials can be nested, but that can make confusing for authors to work with. If you use nesting, create a folder structure that helps keep things organized."]}]},"frontmatter":{"seo":{"title":"Partial Markdoc Tag","description":"Use the partial tag to reuse content throughout your documentation. Includes examples and information for using partials in a Redocly project."}},"tagList":["admonition","group-elements","markdoc-example","markdoc-tag-badge","partial","table"],"title":"Partial Markdoc Tag","lastModified":"2025-05-28T16:01:32.000Z"}