Automatically Assign Categories and Tags to Blog Posts with AI
A few months ago, a content manager reached out with a familiar problem:
“We publish new blog posts every week, but organizing them is a nightmare. Each author uses different tags, and we’re never consistent. Could we use AI to handle this automatically?”
The request was clear - they wanted something that would analyze each new blog post, suggest categories and tags, and keep everything organized without manual editing.
That’s how the Automatically Assign Categories and Tags to Blog Posts with AI workflow came to life.
The Problem
Managing a content-heavy site means balancing creativity with structure.
Writers focus on storytelling, but editors and SEO specialists spend valuable time fixing metadata, ensuring consistent tags, and maintaining content hierarchy.
When posts are stored in GitHub (as Markdown or MDX files), manually reviewing each one is slow and repetitive. The content manager’s team needed a way to automate tagging and centralize metadata tracking - all while keeping control over final approvals.
The Solution: n8n + OpenAI + GitHub + Google Sheets
This workflow uses n8n to create an automated pipeline that:
- Scans a GitHub repository for new Markdown blog posts.
- Analyzes each article’s frontmatter and content using OpenAI GPT-4.1-mini.
- Suggests tags and categories using a structured AI prompt.
- Logs all results in Google Sheets for review and future reference.
The result is a continuous, AI-driven curation system that keeps your content taxonomy consistent and easy to manage.
Who It’s For
- Content creators and editors managing static websites (Astro, Next.js, etc.).
- SEO specialists looking for consistent metadata and topic grouping.
- Developers or teams maintaining Markdown-based blogs in GitHub who want to speed up categorization.
How It Works
Here’s the full process inside the workflow:
-
Form Trigger - Starts the process manually, allowing a user to initiate content analysis on demand.
-
Get Data from Google Sheets - Fetches existing post records to avoid reprocessing articles that were already analyzed.
-
Compare GitHub and Google Sheets - Lists all
.mdor.mdxblog posts in the repository (e.g.,piotr-sikora.com/src/content/blog/pl/) and filters out those already logged. -
Check New Repo Files (Code) - Uses a code node to identify only new blog files needing analysis.
-
Switch Node -
- If no new posts are found → workflow stops and confirms completion.
- If new posts exist → moves to AI analysis.
-
Get Post Content from GitHub - Downloads each article’s Markdown content and reads its metadata.
-
AI Agent (LangChain + OpenAI GPT-4.1-mini) -
- Examines both frontmatter (
---block) and post body. - Suggests categories and tags relevant to the topic.
- Returns structured JSON output for consistent results.
- Examines both frontmatter (
-
Append to Google Sheets - Logs details including:
- File name
- Existing tags and categories
- Proposed AI-generated tags and categories
-
Completion Message - Displays a summary once all new posts are processed.
Requirements
- GitHub account with repository access.
- Google Sheets connection for storing metadata suggestions.
- OpenAI account with API key saved in
openAiApicredentials. - n8n instance (Cloud or self-hosted).
How to Set Up
- Connect your GitHub, Google Sheets, and OpenAI credentials in n8n.
- Update the GitHub node with your repository path (e.g.,
src/content/blog/en/). - In Google Sheets, prepare columns:
FileName,Categories,Proposed Categories,Tags,Proposed Tags.
- Adjust the AI prompt in the LangChain node if you prefer a different tone or tagging logic.
- Run the workflow manually using the Form Trigger node whenever you add new content.
How to Customize
- Change the AI model: Replace GPT-4.1-mini with another LLM (e.g., Claude, Gemini) in the LangChain node.
- Edit the AI prompt: Adjust categorization style, tone, or format.
- Auto-update files: Add a GitHub commit node to write AI-generated metadata back to the Markdown files.
- Automate scheduling: Add a Schedule Trigger to run daily or weekly.
- Integrate notifications: Add Slack or email alerts when new tagging suggestions are available.
Important Notes
- All API keys are stored securely using n8n Credentials — no hardcoding.
- The workflow includes sticky notes explaining key sections:
- Repository setup
- File retrieval and AI tagging logic
- Google Sheets data handling
- Uses a LangChain memory buffer to maintain contextual consistency between multiple posts during analysis.
Where Could You Find the Workflow
You can find this workflow in the n8n Community Workflows section.
If you’re using a self-hosted instance, you can import the .json file directly from the shared repository or from my GitHub profile (link coming soon).
Once imported, connect your credentials and point it to your GitHub content folder — you’re ready to automate tagging instantly.
Do You Need Customization or Another Workflow?
If you’d like to:
- Adjust the AI prompt for specific content niches or languages
- Integrate it with Notion, Airtable, or a headless CMS
- Add real-time updates or Slack notifications
- Or build a completely new automation around your publishing process
I can help you customize or create workflows tailored to your exact needs.
Reach out if you’d like to streamline your editorial pipeline or explore new ways to use AI within your content management setup.
![[n8n workflow] Automatically Assign Categories and Tags to Blog Posts with AI](/_next/image?url=%2Fassets%2Fblog-images%2Fcategory%2Fn8n.png&w=3840&q=75)
