新接触结构化数据
前言
传说将网页加入结构化资料microdata,有助于搜寻排名。今天浅尝schema.org, 这是由Google、Microsoft、Yandex三大巨头,联手定义的。
资源
- 官网: https://schema.org/
- 中文站: https://schema.org.cn/
- Google对各种结构化数据的解释:https://developers.google.com/search/docs/data-types/article?hl=zh_CN
- Google结构化数据测试工具 : https://search.google.com/structured-data/testing-tool/u/0/
- Google富媒体搜索结果测试:https://search.google.com/test/rich-results?utm_campaign=sdtt&utm_medium=code
- 代码生成器:https://technicalseo.com/tools/schema-markup-generator/
成果
折腾了一天,总算定型完成,我的站点都是外贸的产品站点,下列代码不一定适用别人的站点,请自行斟酌。
- 显示2条评价
- 500条评分
- 5分制评分,获得5分
- 平均单价 200美元
- 报价有效截止日为当年的12月31日
首页部分
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"url": "<?php $url = home_url(); echo $url;?>",
"name": "<?php the_field('sytitle', 'option'); ?>"
}
</script>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Product",
"name": "<?php the_field('head_tittle', 'option'); ?>",
"image": "<?php the_field('head_pic', 'option'); ?>",
"description":"<?php the_field('sydescription', 'option'); ?>",
"url":"<?php global $wp; $current_url = home_url(add_query_arg(array(),$wp->request));echo $current_url;?>",
"brand": "输入产品品牌",
"sku": "输入产品编号",
"mpn": "输入产品编号",
"offers": {
"@type": "Offer",
"priceCurrency": "USD",
"price": "200",
"url": "<?php global $wp; $current_url = home_url(add_query_arg(array(),$wp->request));echo $current_url;?>",
"priceValidUntil": "<?php echo date('Y') ?>-12-31",
"availability": "http://schema.org/InStock",
"itemCondition": "http://schema.org/NewCondition"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "5",
"bestRating": "5",
"worstRating": "0",
"ratingCount": "500",
"reviewCount": "500"
},
"review":
[{
"@type": "Review",
"name":"输入评论人",
"reviewBody":"输入评论内容",
"reviewRating": {"@type": "Rating", "ratingValue": "5"},
"author": {"@type": "Person", "name": "输入评论人"},
"publisher": {"@type": "Organization", "name": "输入评论人所在公司"}
},
{
"@type": "Review",
"name":"输入评论人",
"reviewBody":"输入评论内容",
"reviewRating": {"@type": "Rating", "ratingValue": "5"},
"author": {"@type": "Person", "name": "输入评论人"},
"publisher": {"@type": "Organization", "name": "输入评论人所在公司"}
}]
}
}
</script>
产品页部分
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement":[
{
"@type": "ListItem",
"position": 1,
"name": "<?php the_field('sytitle', 'option'); ?>",
"item": "<?php $url = home_url(); echo $url;?>"
},
{
"@type": "ListItem",
"position": 2,
"name": "<?php echo the_title() ?>",
"item": "<?php global $wp; $current_url = home_url(add_query_arg(array(),$wp->request));echo $current_url;?>"
}
]
}
</script>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Product",
"name": "<?php echo the_title() ?>",
"image": "<?php $full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full'); echo $full_image_url[0]; ?>",
"description":"<?php echo the_field('seodescription') ?>",
"url":"<?php global $wp; $current_url = home_url(add_query_arg(array(),$wp->request));echo $current_url;?>",
"brand": "输入产品品牌",
"sku": "输入产品编号<?php the_ID(); ?>",
"mpn": "输入产品编号<?php the_ID(); ?>",
"offers": {
"@type": "Offer",
"priceCurrency": "USD",
"price": "200",
"url": "<?php global $wp; $current_url = home_url(add_query_arg(array(),$wp->request));echo $current_url;?>",
"priceValidUntil": "<?php echo date('Y') ?>-12-31",
"availability": "http://schema.org/InStock",
"itemCondition": "http://schema.org/NewCondition"
},
"aggregateRating": {
"@type": "AggregateRating",
"ratingValue": "5",
"bestRating": "5",
"worstRating": "0",
"ratingCount": "500",
"reviewCount": "500"
},
"review":
[{
"@type": "Review",
"name":"输入评论人",
"reviewBody":"输入评论内容",
"reviewRating": {"@type": "Rating", "ratingValue": "5"},
"author": {"@type": "Person", "name": "输入评论人"},
"publisher": {"@type": "Organization", "name": "输入评论人所在公司"}
},
{
"@type": "Review",
"name":"输入评论人",
"reviewBody":"输入评论内容",
"reviewRating": {"@type": "Rating", "ratingValue": "5"},
"author": {"@type": "Person", "name": "输入评论人"},
"publisher": {"@type": "Organization", "name": "输入评论人所在公司"}
}]
}
}
</script>
- 下一篇:网站首屏设计的个人见解
- 上一篇:重新开始使用Google云字体
It’s actually a cool and useful piece of information. I am happy that you simply shared this helpful information with us. Please keep us informed like this. Thank you for sharing.
非常感谢您的留言,不过为啥要写英文呢?