AI Content Categorization for Static Sites - n8n Workflow

Use this advanced n8n workflow to automatically analyze new blog posts from GitHub using GPT-4, assign SEO categories/tags, and track results in Google Sheets.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Content managers and editors using static site generators (Astro, Next.js).

  • Developers needing to automate metadata generation for markdown files.

  • Teams looking to leverage AI for SEO keyword and category assignment.

  • Users searching for robust n8n templates integrating LangChain and cloud services.

Overview

This expert n8n workflow is designed for content creators, developers, and digital marketers managing static site generators (like Astro or Next.js) where content files live in a GitHub repository. The primary challenge is efficiently assigning relevant tags and categories to new posts without manual review. This specific n8n workflow solves this by using a LangChain AI Agent powered by GPT-4. It intelligently scans your Google Sheet for files already processed, identifies new files in GitHub, retrieves their content, gets structured recommendations from the AI, and logs the results back into Google Sheets. This highly efficient n8n node configuration saves significant editorial time and ensures consistent metadata application across your repository. This is an essential n8n template for modern content operations.

How it Works

This automation is initiated by an n8n trigger, specifically an 'On form submission' n8n node, allowing for manual start.


  1. Data Retrieval and Filtering: The n8n workflow first reads all existing categorized file names from the designated Google Sheet using the 'Get row(s) in sheet' n8n node. Concurrently, it lists all current files in the specified directory on GitHub.

  2. Difference Calculation: The retrieved lists are aggregated and then merged. A custom Code n8n node, titled 'Check new repo files for AI processing', performs a difference calculation, identifying which files exist in GitHub but have not yet been logged in Google Sheets. This step prevents the system from incurring unnecessary costs by reprocessing existing content.

  3. Conditional Execution: A Switch n8n node checks if any new files were found. If the list is empty, the n8n workflow terminates gracefully.

  4. AI Processing Loop: If new files are present, the workflow loops through them. For each file, the 'Get post/article file' n8n node retrieves the full content from GitHub.

  5. Categorization: The content is passed to the AI Agent n8n node, which uses the power of GPT-4 (via the OpenAI Chat Model n8n node) and a detailed system prompt to analyze the post and suggest appropriate categories and tags. A Structured Output Parser n8n node ensures the response is delivered in a reliable JSON format.

  6. Logging Results: Finally, the 'Append rows with posts / article analysis' Google Sheets n8n node records the file name, existing categories/tags, and the AI-proposed categories/tags into your tracking sheet, closing the loop of this powerful n8n workflow.

Installation Guide


  1. Import the n8n template: Copy the provided JSON into your n8n instance using the 'Import Workflow' option.

  2. GitHub Credentials: Update all GitHub n8n node credentials ('List posts/articles/pages' and 'Get post/article file') with your repository authentication.

  3. Google Sheets Setup: Configure the Google Sheets n8n node credentials and ensure the Document ID and Sheet Name match your tracking sheet. This sheet must contain columns for 'FileName', 'Categories', 'Proposed Categories', 'Tags', and 'Proposed Tags'.

  4. OpenAI Credentials: Set up the credentials for the OpenAI Chat Model n8n node. The workflow is configured for gpt-4.1-mini, but you can change the model as needed.

  5. Customize Paths: In the 'List posts/articles/pages' n8n node, define the exact GitHub repository and file path where your content markdown files reside.

  6. Activate: Ensure the n8n workflow is active and test the initial Form Trigger.

Node Details

On form submission (n8n trigger): The starting point of this n8n workflow. It uses a custom form to manually initiate the content categorization process.
List posts/articles/pages (GitHub n8n node): Retrieves a list of all files located in the specified blog content directory (src/content/blog/pl/) on GitHub.
Get row(s) in sheet (Google Sheets n8n node): Reads existing data from the tracking sheet, specifically file names that have already been processed, crucial for optimization.
List FileName only / Remove duplicates (Code n8n node): Filters the Google Sheets data to extract unique file paths and removes any redundant entries.
Check new repo files for AI processing (Code n8n node): This core custom logic n8n node compares the array of paths from GitHub with the array of processed paths from Google Sheets, returning only the list of files that require AI analysis.
Get post/article file (GitHub n8n node): Retrieves the full text content of a single, identified new file, which serves as the input for the AI Agent.
AI Agent (LangChain n8n node): The primary processing unit. It accepts the file content and, guided by a system prompt, analyzes the text to determine highly relevant categories and tags.
OpenAI Chat Model (LangChain n8n node): The language model component, utilizing GPT-4 to perform the categorization task efficiently within the n8n workflow.
Structured Output Parser (LangChain n8n node): Ensures the AI Agent's output is strictly formatted as a JSON object, guaranteeing reliable data mapping downstream.
Append rows with posts / article analysis (Google Sheets n8n node): The final action, which writes the original and proposed category and tag metadata back into the Google Sheet for permanent tracking.

Related n8n Workflows

Free

Nodes: 14 Nodes
Updated: December 26 2025
View all
Created by

Featured*