关于 shopify-content
shopify-content 指导通过 Shopify Admin API 或浏览器自动化创建和管理店铺内容,适合维护商店页面、博客和导航的团队。它还涵盖重定向、SEO 元数据与内容核验。
主要功能
- 01创建和管理页面及博客文章
- 02通过浏览器自动化编辑导航菜单
- 03创建 URL 重定向
- 04更新资源的 SEO 元数据
- 05查询内容以确认发布状态
适用场景
- 01发布商店介绍或常见问题页面
- 02为产品动态创建并安排博客文章
- 03调整主菜单或页脚菜单
- 04更改旧页面的目标地址并更新 SEO
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ jezweb/ claude-skills --skill shopify-content安装后在 Claude Code 中输入/shopify-content确认已加载。
附带文件references/content-types.md
详细介绍
Shopify 内容
创建和管理 Shopify 商店内容——页面、博客文章、导航菜单和 SEO 元数据。通过 Admin API 或浏览器自动化在商店中发布实时内容。
前提条件
- 具有
read_content、write_content作用域的 Admin API 访问令牌(使用 shopify-setup 技能) - 对于导航:
read_online_store_navigation、write_online_store_navigation作用域
工作流
步骤 1:确定内容类型
| 内容类型 | API 支持 | 方法 |
|---|---|---|
| 页面 | 完整 | GraphQL Admin API |
| 博客文章 | 完整 | GraphQL Admin API |
| 导航菜单 | 有限 | 优先使用浏览器自动化 |
| 重定向 | 完整 | REST Admin API |
| SEO 元数据 | 按资源提供 | 对资源使用 GraphQL |
| Metaobjects | 完整 | GraphQL Admin API |
步骤 2a:创建页面
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="...">添加链接 - 避免使用内联样式——样式由主题处理
步骤 2b:创建博客文章
Shopify 博客采用两层结构:Blog(容器)> Article(文章)。
查找或创建博客:
{
blogs(first: 10) {
edges {
node { id title handle }
}
}
}
大多数商店都有一个名为 "News" 的默认博客。在其中创建文章:
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 }
}
}
步骤 2c:更新导航菜单
导航菜单的 API 支持有限。请使用浏览器自动化:
- 前往
https://{store}.myshopify.com/admin/menus - 选择要编辑的菜单(通常是 "Main menu" 或 "Footer menu")
- 添加、重新排序或移除菜单项
- 保存更改
或者,如果 API 版本支持,可使用 GraphQL menuUpdate mutation:
mutation menuUpdate($id: ID!, $items: [MenuItemInput!]!) {
menuUpdate(id: $id, items: $items) {
menu { id title }
userErrors { field message }
}
}
步骤 2d:创建重定向
URL 重定向使用 REST API:
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"
}
}'
步骤 2e:更新 SEO 元数据
SEO 字段位于各个资源(产品、页面、文章)上。通过资源的 mutation 进行更新:
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 }
}
}
步骤 3:验证
查询内容以确认:
{
pages(first: 10, reverse: true) {
edges {
node { id title handle isPublished createdAt }
}
}
}
向用户提供管理后台 URL 和在线 URL,以供查看:
- 管理后台:
https://{store}.myshopify.com/admin/pages - 在线页面:
https://{store}.myshopify.com/pages/{handle}
关键模式
页面与 Metaobject
对于简单内容(关于、联系、常见问题),请使用页面。对于结构化且可重复的内容(团队成员、推荐语、地点),请使用 metaobjects——它们具有类型化字段,且可通过编程方式查询。
博客 SEO
每篇博客文章都应包含:
- SEO 标题:少于 60 个字符,并包含主要关键词
- Meta description:少于 160 个字符,提供有吸引力的摘要
- Handle:包含关键词的简洁 URL 路径
- 带替代文本的图片:用于社交分享和无障碍访问
内容排期
使用文章的 publishDate 安排发布。isPublished: true 的页面会立即发布。
批量内容
对于大量页面(例如地点页面、服务页面),请使用带速率限制的循环:
for page in pages_data:
create_page(page)
sleep(0.5) # Respect rate limits
参考文件
references/content-types.md— API 端点、metaobject 模式和仅限浏览器的操作
评论
支持 Markdown