Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@astrolib/seo

Package Overview
Dependencies
Maintainers
0
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@astrolib/seo

Managing your SEO easier in Astro projects

  • 1.0.0-beta.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.3K
decreased by-7.13%
Maintainers
0
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 04 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc