Add Comments to Your VitePress Site

Comments, Reactions, and Ratings Under Every Docs Page

Let readers ask questions where they get stuck. Extend the default VitePress theme with one layout file, and every page gets a comment section from the Hyvor Talk Vue library.

Installation guide About 5 minutes

Steps to Add Comments to VitePress

Sign up at the Hyvor Talk Console, add your website with your site's domain, and copy the website ID from Settings → Website.

  1. Install the Hyvor Talk Vue library:

    npm install @hyvor/hyvor-talk-vue
  2. Extend the default theme in .vitepress/theme/index.js (create the file if it doesn't exist):

    import DefaultTheme from 'vitepress/theme';
    import Layout from './Layout.vue';
    
    export default {
        extends: DefaultTheme,
        Layout,
    };
  3. Create .vitepress/theme/Layout.vue. It puts the comments in the doc-after slot, using the page path as the page ID. Replace YOUR_WEBSITE_ID with your website ID.

    <script setup>
    import DefaultTheme from 'vitepress/theme';
    import { useRoute, useData } from 'vitepress';
    import { Comments } from '@hyvor/hyvor-talk-vue';
    
    const { Layout } = DefaultTheme;
    const route = useRoute();
    const { frontmatter } = useData();
    </script>
    
    <template>
        <Layout>
            <template #doc-after>
                <ClientOnly>
                    <Comments
                        v-if="frontmatter.comments !== false"
                        :key="route.path"
                        :website-id="YOUR_WEBSITE_ID"
                        :page-id="route.path"
                    />
                </ClientOnly>
            </template>
        </Layout>
    </template>
  4. Run npm run docs:dev and open any page. The comments load below the content.

That's it. Build and deploy your site, and readers can start commenting. If you rename a page later, its old thread stays under the old path. See page-id to use your own fixed IDs instead.

Frequently asked questions

Right after the page content, through the default theme's doc-after slot. VitePress has other layout slots too, if you'd like them somewhere else.

VitePress switches pages without a full reload. Keying the component by the route path makes Vue create a fresh comment section for each page, so readers never see the previous page's thread.

No. Our Vue library works directly in a VitePress theme. One layout file takes the place of a comments plugin.

Yes. Add comments: false to a page's frontmatter. The doc-after slot is also not used by the home layout, so comments won't show up there anyway.

A place for readers to ask questions and point out mistakes, right on the page. You get reply notifications, spam filtering, moderation, and optional ratings to see which pages help.

You can set the colors attribute to light, dark, or os. To follow the theme toggle, bind it to isDark from useData(). See styles.

Yes, a 14-day free trial without a credit card. See pricing for plans.

Start your 14-day free trial now!

14-day free trial
No credit card required
Cancel anytime