DEV Community

Cover image for How to Automate Shopify Metafield Meta Descriptions with Python
Oddshop
Oddshop

Posted on • Originally published at oddshop.work

How to Automate Shopify Metafield Meta Descriptions with Python

Shopify metafield automation is a time sink for developers who want to optimize product pages at scale. Without tooling, updating meta descriptions manually for hundreds of products becomes a tedious task. It's a gap that leaves SEO performance on the table, especially when product data lives in metafields and requires custom formatting for each item.

The Manual Way (And Why It Breaks)

A developer working with Shopify product data often finds themselves in a cycle of repetitive clicks and copy-paste actions. First, they download a CSV or JSON export of their products. Then they open the file, locate each product row, and manually edit the meta description field. If the store uses metafields, they must look up values like material, type, or a custom description. They paste these into templates, format them, and repeat for every product. This process becomes error-prone and impossibly slow when managing thousands of SKUs. It's not just about efficiency — it's about how to scale product-level SEO using shopify product data effectively.

The Python Approach

Here's a minimal Python script to automate meta description generation from a CSV of Shopify product data. It uses pandas to load data and fills in placeholders from metafields, simulating what the full tool does. This script handles only a few rows but shows how metafield automation could be done at a basic level. It doesn't support bulk exports or fallbacks — those are features in the full tool.

import pandas as pd

# Load product data from CSV
products_df = pd.read_csv('products.csv')

# Define a template with metafield placeholders
template = "Handmade {material} {product_type}. {custom.description_short}"

# Function to generate meta description using metafield values
def generate_meta_description(row):
    # Replace placeholders with actual metafield values from row
    meta_desc = template.format(
        material=row.get('material', ''),
        product_type=row.get('product_type', ''),
        custom_description_short=row.get('custom.description_short', '')
    )
    return meta_desc

# Apply the function to each row
products_df['meta_description'] = products_df.apply(generate_meta_description, axis=1)

# Save updated CSV
products_df.to_csv('meta_updated.csv', index=False)
Enter fullscreen mode Exit fullscreen mode

This approach uses pandas to load and process a dataset, but it doesn’t support fallbacks, bulk processing, or different output formats like HTML. It’s a starting point, not a full solution.

What the Full Tool Handles

  • Parse Shopify product CSV/JSON exports — pulls in product titles, descriptions, and metafield values from structured exports
  • Template engine for meta descriptions — allows developers to build dynamic templates using {braces} to reference metafields
  • Bulk processing — handles hundreds of products in one run, making it scalable for large inventories
  • Output to CSV or HTML — creates ready-to-import files or direct-use HTML snippets
  • Custom fallback values — prevents empty meta descriptions by providing default text when metafields are missing
  • Shopify metafield automation — gives developers a way to automate meta description creation that’s tied directly to custom product data

Running It

Here’s how to run the tool with a real-world example:

metagen --input products.csv --template "Handmade {material} {product_type}. {custom.description_short}" --output meta_updated.csv
Enter fullscreen mode Exit fullscreen mode

This command tells the tool to read from a product CSV, use a custom template to generate descriptions based on metafields, and write the results to a new CSV file. The flags define input, format, and output, and the resulting file is ready for import into Shopify or use in bulk SEO tools.

Get the Script

Skip the build. This tool is already polished and ready to use. If you wanted to write one yourself, this article gives you the basic idea, but it won’t handle edge cases or performance at scale.

Download Metafield Meta Description Generator →

$29 one-time. No subscription. Works on Windows, Mac, and Linux.


Built by OddShop — Python automation tools for developers and businesses.

Top comments (0)