shopify-content

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Shopify Content

Shopify 内容管理

Create and manage Shopify store content — pages, blog posts, navigation menus, and SEO metadata. Produces live content in the store via the Admin API or browser automation.
创建并管理Shopify店铺内容——页面、博客文章、导航菜单及SEO元数据。通过Admin API或浏览器自动化在店铺中生成实时内容。

Prerequisites

前置条件

  • Admin API access token with
    read_content
    ,
    write_content
    scopes (use shopify-setup skill)
  • For navigation:
    read_online_store_navigation
    ,
    write_online_store_navigation
    scopes
  • 具备
    read_content
    write_content
    权限的Admin API访问令牌(使用shopify-setup技能)
  • 若管理导航:需具备
    read_online_store_navigation
    write_online_store_navigation
    权限

Workflow

工作流程

Step 1: Determine Content Type

步骤1:确定内容类型

Content TypeAPI SupportMethod
PagesFullGraphQL Admin API
Blog postsFullGraphQL Admin API
Navigation menusLimitedBrowser automation preferred
RedirectsFullREST Admin API
SEO metadataPer-resourceGraphQL on the resource
MetaobjectsFullGraphQL Admin API
内容类型API支持方法
页面完全支持GraphQL Admin API
博客文章完全支持GraphQL Admin API
导航菜单有限支持推荐使用浏览器自动化
重定向完全支持REST Admin API
SEO元数据基于资源针对资源调用GraphQL
Metaobjects完全支持GraphQL Admin API

Step 2a: Create Pages

步骤2a:创建页面

bash
curl -s https://{store}/admin/api/2025-01/graphql.json \
  -H "Content-Type: application/json" \
  -H "X-Shopify-Access-Token: {token}" \
  -d '{
    "query": "mutation pageCreate($page: PageCreateInput!) { pageCreate(page: $page) { page { id title handle } userErrors { field message } } }",
    "variables": {
      "page": {
        "title": "About Us",
        "handle": "about",
        "body": "<h2>Our Story</h2><p>Content here...</p>",
        "isPublished": true,
        "seo": {
          "title": "About Us | Store Name",
          "description": "Learn about our story and mission."
        }
      }
    }
  }'
Page body accepts HTML. Keep it semantic:
  • Use
    <h2>
    through
    <h6>
    for headings (the page title is
    <h1>
    )
  • Use
    <p>
    ,
    <ul>
    ,
    <ol>
    for body text
  • Use
    <a href="...">
    for links
  • Avoid inline styles — the theme handles styling
bash
curl -s https://{store}/admin/api/2025-01/graphql.json \
  -H "Content-Type: application/json" \
  -H "X-Shopify-Access-Token: {token}" \
  -d '{
    "query": "mutation pageCreate($page: PageCreateInput!) { pageCreate(page: $page) { page { id title handle } userErrors { field message } } }",
    "variables": {
      "page": {
        "title": "About Us",
        "handle": "about",
        "body": "<h2>Our Story</h2><p>Content here...</p>",
        "isPublished": true,
        "seo": {
          "title": "About Us | Store Name",
          "description": "Learn about our story and mission."
        }
      }
    }
  }'
页面主体支持HTML格式,需保持语义化:
  • 使用
    <h2>
    <h6>
    作为标题(页面标题默认是
    <h1>
  • 使用
    <p>
    <ul>
    <ol>
    作为正文文本
  • 使用
    <a href="...">
    添加链接
  • 避免内联样式——主题会处理样式渲染

Step 2b: Create Blog Posts

步骤2b:创建博客文章

Shopify blogs have a two-level structure: Blog (container) > Article (post).
Find or create a blog:
graphql
{
  blogs(first: 10) {
    edges {
      node { id title handle }
    }
  }
}
Most stores have a default blog called "News". Create articles in it:
graphql
mutation {
  articleCreate(article: {
    blogId: "gid://shopify/Blog/123"
    title: "New Product Launch"
    handle: "new-product-launch"
    contentHtml: "<p>We're excited to announce...</p>"
    author: { name: "Store Team" }
    tags: ["news", "products"]
    isPublished: true
    publishDate: "2026-02-22T00:00:00Z"
    seo: {
      title: "New Product Launch | Store Name"
      description: "Announcing our latest product range."
    }
    image: {
      src: "https://example.com/blog-image.jpg"
      altText: "New product collection"
    }
  }) {
    article { id title handle }
    userErrors { field message }
  }
}
Shopify博客采用两级结构:Blog(博客容器) > Article(博客文章)
查找或创建博客容器:
graphql
{
  blogs(first: 10) {
    edges {
      node { id title handle }
    }
  }
}
大多数店铺都有一个名为“News”的默认博客容器。在其中创建博客文章:
graphql
mutation {
  articleCreate(article: {
    blogId: "gid://shopify/Blog/123"
    title: "New Product Launch"
    handle: "new-product-launch"
    contentHtml: "<p>We're excited to announce...</p>"
    author: { name: "Store Team" }
    tags: ["news", "products"]
    isPublished: true
    publishDate: "2026-02-22T00:00:00Z"
    seo: {
      title: "New Product Launch | Store Name"
      description: "Announcing our latest product range."
    }
    image: {
      src: "https://example.com/blog-image.jpg"
      altText: "New product collection"
    }
  }) {
    article { id title handle }
    userErrors { field message }
  }
}

Step 2c: Update Navigation Menus

步骤2c:更新导航菜单

Navigation menus have limited API support. Use browser automation:
  1. Navigate to
    https://{store}.myshopify.com/admin/menus
  2. Select the menu to edit (typically "Main menu" or "Footer menu")
  3. Add, reorder, or remove menu items
  4. Save changes
Alternatively, use the GraphQL
menuUpdate
mutation if the API version supports it:
graphql
mutation menuUpdate($id: ID!, $items: [MenuItemInput!]!) {
  menuUpdate(id: $id, items: $items) {
    menu { id title }
    userErrors { field message }
  }
}
导航菜单的API支持有限,推荐使用浏览器自动化:
  1. 访问
    https://{store}.myshopify.com/admin/menus
  2. 选择要编辑的菜单(通常是“主导航”或“页脚导航”)
  3. 添加、重新排序或删除菜单项
  4. 保存更改
如果API版本支持,也可以使用GraphQL的
menuUpdate
突变:
graphql
mutation menuUpdate($id: ID!, $items: [MenuItemInput!]!) {
  menuUpdate(id: $id, items: $items) {
    menu { id title }
    userErrors { field message }
  }
}

Step 2d: Create Redirects

步骤2d:创建重定向

URL redirects use the REST API:
bash
curl -s https://{store}/admin/api/2025-01/redirects.json \
  -H "Content-Type: application/json" \
  -H "X-Shopify-Access-Token: {token}" \
  -d '{
    "redirect": {
      "path": "/old-page",
      "target": "/new-page"
    }
  }'
URL重定向使用REST API:
bash
curl -s https://{store}/admin/api/2025-01/redirects.json \
  -H "Content-Type: application/json" \
  -H "X-Shopify-Access-Token: {token}" \
  -d '{
    "redirect": {
      "path": "/old-page",
      "target": "/new-page"
    }
  }'

Step 2e: Update SEO Metadata

步骤2e:更新SEO元数据

SEO fields are on each resource (product, page, article). Update via the resource's mutation:
graphql
mutation {
  pageUpdate(page: {
    id: "gid://shopify/Page/123"
    seo: {
      title: "Updated SEO Title"
      description: "Updated meta description under 160 chars."
    }
  }) {
    page { id title }
    userErrors { field message }
  }
}
SEO字段属于各个资源(产品、页面、文章),可通过对应资源的突变操作进行更新:
graphql
mutation {
  pageUpdate(page: {
    id: "gid://shopify/Page/123"
    seo: {
      title: "Updated SEO Title"
      description: "Updated meta description under 160 chars."
    }
  }) {
    page { id title }
    userErrors { field message }
  }
}

Step 3: Verify

步骤3:验证

Query back the content to confirm:
graphql
{
  pages(first: 10, reverse: true) {
    edges {
      node { id title handle isPublished createdAt }
    }
  }
}
Provide the admin URL and the live URL for the user to review:
  • Admin:
    https://{store}.myshopify.com/admin/pages
  • Live:
    https://{store}.myshopify.com/pages/{handle}

查询已创建的内容以确认结果:
graphql
{
  pages(first: 10, reverse: true) {
    edges {
      node { id title handle isPublished createdAt }
    }
  }
}
提供管理后台链接和前台链接供用户查看:
  • 后台链接:
    https://{store}.myshopify.com/admin/pages
  • 前台链接:
    https://{store}.myshopify.com/pages/{handle}

Critical Patterns

关键实践模式

Page vs Metaobject

页面 vs Metaobject

For simple content (About, Contact, FAQ), use pages. For structured, repeatable content (team members, testimonials, locations), use metaobjects — they have typed fields and can be queried programmatically.
对于简单内容(关于我们、联系我们、常见问题),使用页面。对于结构化、可重复的内容(团队成员、客户评价、门店地址),使用Metaobject——它们具备类型化字段,可通过编程方式查询。

Blog SEO

博客SEO优化

Every blog post should have:
  • SEO title: under 60 characters, includes primary keyword
  • Meta description: under 160 characters, compelling summary
  • Handle: clean URL slug with keywords
  • Image with alt text: for social sharing and accessibility
每篇博客文章都应包含:
  • SEO标题:不超过60字符,包含核心关键词
  • 元描述:不超过160字符,具有吸引力的摘要
  • Handle:简洁的URL别名,包含关键词
  • 带替代文本的图片:用于社交分享及无障碍访问

Content Scheduling

内容排期

Use
publishDate
on articles for scheduled publishing. Pages publish immediately when
isPublished: true
.
对文章使用
publishDate
字段进行定时发布。页面设置
isPublished: true
后会立即发布。

Bulk Content

批量内容处理

For many pages (e.g. location pages, service pages), use a loop with rate limiting:
bash
for page in pages_data:
    create_page(page)
    sleep(0.5)  # Respect rate limits

对于大量页面(如门店地址页、服务页),使用循环并添加速率限制:
bash
for page in pages_data:
    create_page(page)
    sleep(0.5)  # Respect rate limits

Reference Files

参考文件

  • references/content-types.md
    — API endpoints, metaobject patterns, and browser-only operations
  • references/content-types.md
    — API端点、Metaobject模式及仅支持浏览器操作的说明