Skip to main content

How to indicate AI-assisted content in a Docusaurus blog

A step-by-step guide to show when a blog post has been written with the help of an AI like Google Gemini, by adding an icon and an author.

· 7 min read
View raw
Christophe
Markdown, WSL and Docker lover ~ Insatiable curious.
Google Gemini
AI Assistant
Cet article existe aussi en français — lire la version française.

How to indicate AI-assisted content in a Docusaurus blog

⚡
TL;DR

This blog post explains how to indicate AI-assisted content in a Docusaurus blog by adding an icon and a co-author.

In the age of powerful AI assistants like Google Gemini, it's becoming increasingly common to use them for content creation, brainstorming, or even coding. As a content creator, I believe in transparency with my audience. If an AI has significantly contributed to a piece of content, the reader should know.

Two concrete cases where I lean on an AI and therefore raise this flag: Automating TL;DR Summaries with Gemini AI and AI-Powered Code Tooltips in Docusaurus.

This blog post is a step-by-step guide on how I implemented an "AI Assisted" indicator in my Docusaurus blog. When I add ai_assisted: true to my YAML post's front matter, two things happen automatically:

  1. A small "AI Assisted" icon appears next to the post's date and reading time.
  2. "Google Gemini" is added as a co-author.

Here's how you can do the same for your own blog.

The Result​

Here's what a single ai_assisted: true flag produces, rendered on an actual post of this blog:

The "AI Assisted" badge and the Google Gemini co-author, rendered on a real post header

The icon sits right next to the date and reading time, and the AI shows up as a real co-author alongside the human one — nothing hidden, nothing to click to reveal.

Why Do This​

As a content creator, I believe in transparency with my audience. If an AI has significantly contributed to a piece of content, the reader should know — not buried in a footer, not omitted, right there in the header where the date and reading time already are. A single front-matter flag drives both the icon and the co-author, so there's no separate step to forget.

Step 1: The ai_assisted Front Matter​

The entire process is driven by a single flag in the front matter of your blog posts. This is the simplest part: just add ai_assisted: true to any post where you've had help from an AI.

---
slug: my-awesome-post
title: My Awesome Post
authors: [christophe]
ai_assisted: true
---
... content ...

This is a front matter section (metadata) for a blog post or similar document, written in YAML format. It defines properties like the post's URL slug, title, author, and whether it was created with AI assistance, followed by the actual content below.

This flag will be the trigger for all the logic we'll build next.

Step 2: Creating the AIIcon Component​

First, let's create the visual component for our indicator. This is a simple React component that displays an icon and the text "AI Assisted."

📦 Project setup: src/components/Blog/AIIcon
Help

Need help here? Click the "Help" button above for setup instructions.

Step 3: Displaying the Icon with Swizzling​

Now we need to make this component appear in our post header. To do this, we need to modify some of Docusaurus's core theme components. This is where swizzling comes in. Swizzling is a Docusaurus feature that allows you to replace a theme component with your own customized version.

In this implementation, the logic is spread across three components: BlogPostItem, its Header, and the Info section within the header. We'll need to swizzle all three.

Run the following commands in your terminal:

>user@machine: ~/yourproject

This will copy the original theme files into your src/theme directory, ready for you to edit.

3.1. Modify src/theme/BlogPostItem/index.js​

Here, we'll import our new AIIcon and decide if it should be rendered based on the front matter.

src/theme/BlogPostItem/index.js
import AIIcon from "@site/src/components/Blog/AIIcon";
import { useBlogPost } from "@docusaurus/plugin-content-blog/client";
import BlogPostItemContainer from "@theme/BlogPostItem/Container";
import BlogPostItemContent from "@theme/BlogPostItem/Content";
import BlogPostItemFooter from "@theme/BlogPostItem/Footer";
import BlogPostItemHeader from "@theme/BlogPostItem/Header";

export default function BlogPostItem({ children, className }) {
const { metadata, isBlogPostPage } = useBlogPost();
const { frontMatter } = metadata;
const containerClassName = useContainerClassName();
const aiIcon = frontMatter.ai_assisted && isBlogPostPage ? <AIIcon /> : null;

return (
<BlogPostItemContainer className={clsx(containerClassName, className)}>
<BlogPostItemHeader aiIcon={aiIcon} />
<BlogPostItemContent>{children}</BlogPostItemContent>
<BlogPostItemFooter />
</BlogPostItemContainer>
);
}

3.2. Modify src/theme/BlogPostItem/Header/index.js​

This component just needs to accept the aiIcon prop and pass it down to its child.

src/theme/BlogPostItem/Header/index.js
import React from 'react';
import BlogPostItemHeaderTitle from '@theme/BlogPostItem/Header/Title';
import BlogPostItemHeaderInfo from '@theme/BlogPostItem/Header/Info';
import BlogPostItemHeaderAuthors from '@theme/BlogPostItem/Header/Authors';

// Add aiIcon to the function signature
export default function BlogPostItemHeader({aiIcon}) {
return (
<header>
<BlogPostItemHeaderTitle />
<BlogPostItemHeaderInfo aiIcon={aiIcon} />
<BlogPostItemHeaderAuthors />
</header>
);
}

3.3. Modify src/theme/BlogPostItem/Header/Info/index.js​

Finally, this component receives the prop and renders it.

src/theme/BlogPostItem/Header/Info/index.js
import React from "react";
import clsx from "clsx";
import { translate } from "@docusaurus/Translate";
// ... other imports

function Spacer() {
return <>{" · "}</>;
}

export default function BlogPostItemHeaderInfo({ className, aiIcon }) {
const { metadata } = useBlogPost();
const { date, readingTime } = metadata;
// ... other code

return (
<div className={clsx(styles.container, "margin-vert--md", className)}>
<DateTime date={date} formattedDate={formatDate(date)} />
{typeof readingTime !== "undefined" && (
<>
<Spacer />
<ReadingTime readingTime={readingTime} />
</>
)}
{aiIcon && <Spacer />}
{aiIcon}
</div>
);
}

With these changes, the "AI Assisted" icon will now appear on any blog post with the correct front matter.

Step 4: Adding "Google Gemini" as an Author​

Just like the icon, we can automatically add an author.

4.1. Define the AI Author​

First, define your AI author in blog/authors.yml.

gemini:
name: Google Gemini
title: AI Assistant
url: https://gemini.google.com/
image_url: /img/gemini-logo.webp

This is a YAML configuration block defining metadata for Google's Gemini AI service. It specifies the service name, a user-facing title, where to access it, and where to find its logo image.

4.2. Swizzle the Authors Component​

We need to swizzle one more component to inject the author logic.

>user@machine: ~/yourproject

4.3. Modify src/theme/BlogPostItem/Header/Authors/index.js​

Now, edit the newly created file to add the logic. We read the ai_assisted flag from the front matter and, if it's true, we push our "Gemini" author object into the list of authors.

src/theme/BlogPostItem/Header/Authors/index.js
import React from "react";
import clsx from "clsx";
import { useBlogPost } from "@docusaurus/plugin-content-blog/client";
import BlogAuthor from "@theme/Blog/Components/Author";
import styles from "./styles.module.css";

export default function BlogPostItemHeaderAuthors({ className }) {
const {
metadata: { authors },
frontMatter,
assets,
} = useBlogPost();

const allAuthors = [...authors];

if (frontMatter.ai_assisted) {
const geminiAuthor = {
name: "Google Gemini",
title: "AI Assistant",
url: "https://gemini.google.com/",
imageURL: "/img/gemini-logo.webp",
};
if (!allAuthors.find((a) => a.name === geminiAuthor.name)) {
allAuthors.push(geminiAuthor);
}
}

const authorsCount = allAuthors.length;
// ... rest of the component

Conclusion​

That's it! With a few component customizations, you now have a robust system for transparently indicating AI assistance in your blog. This approach keeps your Markdown files clean (just one flag to add) and centralizes the logic within your Docusaurus theme, making it easy to manage and update. By being open about your process, you can build greater trust with your audience.

This ai_assisted flag is what you'll see on other posts where AI played a real role, like How I used Google Gemini Nano Banana on my blog (generating all my banner images) or Lovable.dev (an AI-driven app builder) — the very post the screenshot above was taken from.


Was this article helpful?
Did you try the steps in this article?
🦋 Join the conversation on BlueskyRequires a free Bluesky account to like, repost or comment. This block talks to Bluesky's public API directly from your browser (no cookies, no sign-in) — that means your IP address reaches Bluesky's servers just by this section loading.

Loading comments…