shopify-content
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseShopify 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_contentscopes (use shopify-setup skill)write_content - For navigation: ,
read_online_store_navigationscopeswrite_online_store_navigation
- 具备、
read_content权限的Admin API访问令牌(使用shopify-setup技能)write_content - 若管理导航:需具备、
read_online_store_navigation权限write_online_store_navigation
Workflow
工作流程
Step 1: Determine Content Type
步骤1:确定内容类型
| Content Type | API Support | Method |
|---|---|---|
| Pages | Full | GraphQL Admin API |
| Blog posts | Full | GraphQL Admin API |
| Navigation menus | Limited | Browser automation preferred |
| Redirects | Full | REST Admin API |
| SEO metadata | Per-resource | GraphQL on the resource |
| Metaobjects | Full | GraphQL 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 through
<h2>for headings (the page title is<h6>)<h1> - Use ,
<p>,<ul>for body text<ol> - Use for links
<a href="..."> - 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:
- Navigate to
https://{store}.myshopify.com/admin/menus - Select the menu to edit (typically "Main menu" or "Footer menu")
- Add, reorder, or remove menu items
- Save changes
Alternatively, use the GraphQL mutation if the API version supports it:
menuUpdategraphql
mutation menuUpdate($id: ID!, $items: [MenuItemInput!]!) {
menuUpdate(id: $id, items: $items) {
menu { id title }
userErrors { field message }
}
}导航菜单的API支持有限,推荐使用浏览器自动化:
- 访问
https://{store}.myshopify.com/admin/menus - 选择要编辑的菜单(通常是“主导航”或“页脚导航”)
- 添加、重新排序或删除菜单项
- 保存更改
如果API版本支持,也可以使用GraphQL的突变:
menuUpdategraphql
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 on articles for scheduled publishing. Pages publish immediately when .
publishDateisPublished: true对文章使用字段进行定时发布。页面设置后会立即发布。
publishDateisPublished: trueBulk 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 limitsReference Files
参考文件
- — API endpoints, metaobject patterns, and browser-only operations
references/content-types.md
- — API端点、Metaobject模式及仅支持浏览器操作的说明
references/content-types.md