Skip to content

Adding Content

ChaiDocs organizes content using a hierarchy of tracks, sub-tracks, and individual pages. This guide will walk you through adding new content to existing tracks or creating entirely new tracks.

Adding Pages To Existing Track

Add new pages in docs by creating .md or .mdx files in src/content/docs/. The platform supports organizing files using sub-folders to create multiple path segments in the URL.

For example, the following file structure will generate pages at the following URLs:

  • docs.chaicode.com/web-dev/javascript/intro.md
  • docs.chaicode.com/devops/getting-started.md
  • Directorysrc/
    • Directorycontent/
      • Directorydocs/
        • Directoryweb-dev/
          • Directoryjavascript/
            • intro.md
        • Directorydevops/
          • getting-started.md

Best Practices

  • The file name appears in the URL path, so choose descriptive names
  • Use lowercase letters and hyphens for file names (e.g. getting-started.mdx, not Getting Started.mdx)
  • Prefer using .mdx files over .md for enhanced content features and component support
  • Use the frontmatter to add metadata to your pages

Adding New Tracks

To create an entirely new track section:

  1. Create a new folder in src/content/docs/

  2. Update astro.config.mjs to add the new track to the sidebar configuration

    astro.config.mjs
    export default defineConfig({
    ...
    sidebar: [
    {label: "contribute", autogenerate: {directory: "contribute"}},
    {label: "web-dev", autogenerate: {directory: "web-dev"}},
    {label: "data-science", autogenerate: {directory: "data-science"}},
    ],
    ...
    })

This change will automatically generate a new sidebar group called “data-science” based on the contents of the data-science directory.

The new track will be accessible at docs.chaicode.com/data-science/introduction.

  • Directorysrc/
    • Directorycontent/
      • Directorydocs/
        • Directorydata-science/
          • introduction.mdx

Every documentation page needs frontmatter to define its metadata. We are going to understand about frontmatter in the next section.

Start your journey with ChaiCode

All of our courses are available on chaicode.com. Feel free to check them out.