Astro SIO - @astrolib/seo (英语)
Astro SEO 在Astro项目中,它是一个集成体,它使管理你的SEO更加容易。 它完全基于优秀的 下个 SEO 图书馆
使用量
Astro SEO 将它添加到您想要添加 SEO 属性的页面中。 一旦在页面中包含,您就通过一个配置对象,并带有页面的SEO属性. 可以在页面级别上动态生成,或者在某些情况下,您的 API 可以返回 SEO 对象 .
设置
首先,安装它:
npm install @astrolib/seo
或者说
yarn add @astrolib/seo
添加到页面
您需要导入 @astrolib/seo 并添加想要的属性。 这能证明.. <head> 为SEO。 只需至少增加一个标题和描述.
仅列出标题和说明的例子:
---
import { AstroSeo } from '@astrolib/seo';
---
<AstroSeo
title="Simple Usage Example"
description="A short description goes here."
/>
不过 Astro SEO 给您更多的选项,您可以添加。 以下为一页的典型例子.
典型的页面示例 :
---
import { AstroSeo } from '@astrolib/seo';
---
<AstroSeo
title="Using More of Config"
description="This example uses more of the available config options."
canonical="https://www.canonical.ie/"
openGraph={{
url: 'https://www.url.ie/a',
title: 'Open Graph Title',
description: 'Open Graph Description',
images: [
{
url: 'https://www.example.ie/og-image-01.jpg',
width: 800,
height: 600,
alt: 'Og Image Alt',
type: 'image/jpeg',
},
{
url: 'https://www.example.ie/og-image-02.jpg',
width: 900,
height: 800,
alt: 'Og Image Alt Second',
type: 'image/jpeg',
},
{ url: 'https://www.example.ie/og-image-03.jpg' },
{ url: 'https://www.example.ie/og-image-04.jpg' },
],
site_name: 'SiteName',
}}
twitter={{
handle: '@handle',
site: '@site',
cardType: 'summary_large_image',
}}
/>
选项
| 财产 | 类型 | 说明 |
|---|---|---|
titleTemplate | 字符串 | 允许您设置将添加到标题中的标题模板 |
title | 字符串 | 设置页面的元标题 |
noindex | 布尔 | 设定页面是否索引 |
nofollow | 布尔 | 设定是否跟踪页面 |
robotsProps | 对象 | 设置更多元信息 X-Robots-Tag |
description | 字符串 | 设置页面元描述 |
canonical | 字符串 | 设置页条 |
mobileAlternate.media | 字符串 | 设定移动网站的屏幕大小 |
mobileAlternate.href | 字符串 | 设置移动页面替代 URL |
languageAlternates | 数组 | 设置替代 urls 的语言 。 期望形状对象的阵列 : { hrefLang: string, href: string } |
additionalMetaTags | 数组 | 允许您添加此处未记录的元标记 . |
additionalLinkTags | 数组 | 允许您添加此处未记录的链接标签 . |
twitter.cardType | 字符串 | 牌型,将是一个 summary, (中文(简体) ), summary_large_image, (中文(简体) ), app,或 player |
twitter.site | 字符串 | @ 用户名用于卡脚中使用的网站 |
twitter.handle | 字符串 | @ 内容创建者/ 作者的用户名( 输出为 twitter:creator(中文(简体) ) |
facebook.appId | 字符串 | 用于Facebook Insights, 您必须在您的页面中添加 facebook app ID |
openGraph.url | 字符串 | 您对象的 Canonial URL 将在图中用作永久 ID |
openGraph.type | 字符串 | 您对象的类型 。 根据您指定的类型, 可能还需要其他属性 |
openGraph.title | 字符串 | 打开的图表标题, 可能与您的元标题不同 . |
openGraph.description | 字符串 | 开放式的图表描述,这可以不同于您的元描述. |
openGraph.images | 数组 | 一系列图像(对象)被社交媒体平台所使用,放行等作为预览. 如果提供了多次, 您可以在共享时选择一次 . |
openGraph.videos | 数组 | 视频阵列( 对象) |
openGraph.locale | 字符串 | 打开的图表标记被标记在其中。 格式语言 TERRITORY. 默认为 en US. |
openGraph.site_name | 字符串 | 如果您的对象属于一个更大的网站,则应显示整个网站的名称. |
openGraph.profile.firstName | 字符串 | 人名出处. |
openGraph.profile.lastName | 字符串 | 人姓为相. |
openGraph.profile.username | 字符串 | 人物用户名. |
openGraph.profile.gender | 字符串 | 人之性别. |
openGraph.book.authors | 字符串 [] | 文章作家. |
openGraph.book.isbn | 字符串 | 这个 ISBN (英语) |
openGraph.book.releaseDate | 约会时间 | 该书发行日期. |
openGraph.book.tags | 字符串 [] | 与本书相关的标记词 . |
openGraph.article.publishedTime | 约会时间 | 文章首次发表时. |
openGraph.article.modifiedTime | 约会时间 | 上次修改文章时. |
openGraph.article.expirationTime | 约会时间 | 文章后出后出后. |
openGraph.article.authors | 字符串 [] | 文章作家. |
openGraph.article.section | 字符串 | 高档科名. 例如,技术 |
openGraph.article.tags | 字符串 [] | 与本条相关的标记词 . |