1.0.0-beta.5 • Published 5 months ago

@astrolib/seo v1.0.0-beta.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Astro SEO - @astrolib/seo

Astro SEO is an integration that makes managing your SEO easier in Astro projects. It is fully based on the excellent Next SEO library

Usage

Astro SEO works by including it on pages where you would like SEO attributes to be added. Once included on the page you pass it a configuration object with the page's SEO properties. This can be dynamically generated at a page level or in some cases your API may return an SEO object.

Setup

First, install it:

npm install @astrolib/seo

or

yarn add @astrolib/seo

Add SEO to Page

Then you need to import @astrolib/seo and add the desired properties. This will render out the tags in the <head> for SEO. At a bare minimum, you should add a title and description.

Example with just title and description:

---
import { AstroSeo } from '@astrolib/seo';
---

<AstroSeo
  title="Simple Usage Example"
  description="A short description goes here."
/>

But Astro SEO gives you many more options that you can add. See below for a typical example of a page.

Typical page example:

---
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',
  }}
/>

Options

PropertyTypeDescription
titleTemplatestringAllows you to set default title template that will be added to your title
titlestringSet the meta title of the page
noindexbooleanSets whether page should be indexed or not
nofollowbooleanSets whether page should be followed or not
robotsPropsObjectSet the more meta information for the X-Robots-Tag
descriptionstringSet the page meta description
canonicalstringSet the page canonical url
mobileAlternate.mediastringSet what screen size the mobile website should be served from
mobileAlternate.hrefstringSet the mobile page alternate url
languageAlternatesarraySet the language of the alternate urls. Expects array of objects with the shape: { hrefLang: string, href: string }
additionalMetaTagsarrayAllows you to add a meta tag that is not documented here.
additionalLinkTagsarrayAllows you to add a link tag that is not documented here.
twitter.cardTypestringThe card type, which will be one of summary, summary_large_image, app, or player
twitter.sitestring@username for the website used in the card footer
twitter.handlestring@username for the content creator / author (outputs as twitter:creator)
facebook.appIdstringUsed for Facebook Insights, you must add a facebook app ID to your page to for it
openGraph.urlstringThe canonical URL of your object that will be used as its permanent ID in the graph
openGraph.typestringThe type of your object. Depending on the type you specify, other properties may also be required
openGraph.titlestringThe open graph title, this can be different than your meta title.
openGraph.descriptionstringThe open graph description, this can be different than your meta description.
openGraph.imagesarrayAn array of images (object) to be used by social media platforms, slack etc as a preview. If multiple supplied you can choose one when sharing.
openGraph.videosarrayAn array of videos (object)
openGraph.localestringThe locale the open graph tags are marked up in. Of the format language_TERRITORY. Default is en_US.
openGraph.site_namestringIf your object is part of a larger web site, the name which should be displayed for the overall site.
openGraph.profile.firstNamestringPerson's first name.
openGraph.profile.lastNamestringPerson's last name.
openGraph.profile.usernamestringPerson's username.
openGraph.profile.genderstringPerson's gender.
openGraph.book.authorsstring[]Writers of the article.
openGraph.book.isbnstringThe ISBN
openGraph.book.releaseDatedatetimeThe date the book was released.
openGraph.book.tagsstring[]Tag words associated with this book.
openGraph.article.publishedTimedatetimeWhen the article was first published.
openGraph.article.modifiedTimedatetimeWhen the article was last changed.
openGraph.article.expirationTimedatetimeWhen the article is out of date after.
openGraph.article.authorsstring[]Writers of the article.
openGraph.article.sectionstringA high-level section name. E.g. Technology
openGraph.article.tagsstring[]Tag words associated with this article.
1.0.0-beta.5

5 months ago

1.0.0-beta.2

9 months ago

1.0.0-beta.3

9 months ago

1.0.0-beta.4

9 months ago

1.0.0-beta.0

9 months ago

1.0.0-beta.1

9 months ago

0.5.0

9 months ago

0.5.2

9 months ago

0.6.0

9 months ago

0.5.1

9 months ago

0.4.0

11 months ago

0.3.1

11 months ago

0.2.2

11 months ago

0.3.0

1 year ago

0.2.1

2 years ago

0.2.0

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago