Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Astro.request.canonicalURL has been moved to Astro.canonicalURL #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ Propname | Type | Description
------------ | ------------- | -------------
title | string | The title of the page.
description | string | Text that gives a concise description of what your page is about.
canonical | string | Prevent duplicate content issues by specifying the "canonical" or "preferred" url of a web page. If you don't define this, `Astro.request.canonicalURL.href` will be used as the default value.
canonical | string | Prevent duplicate content issues by specifying the "canonical" or "preferred" url of a web page. If you don't define this, `Astro.canonicalURL.href` will be used as the default value.
noindex | boolean | Set this to true if you don't want search engines to index your page. Since this is an SEO component, this gets set to `false` by default. This way, indexing is strictly opt-out.
nofollow | boolean | Set this to true if you don't want search engines to follow links on your page. Since this is an SEO component, this gets set to `false` by default. This way, following links is strictly opt-out.
openGraph.basic.title | string | Set the title Open Graph should use. __In most situations, this should be _different_ from the value of the `title` prop.__ See [this tweet](https://twitter.com/jon_neal/status/1428721238071988237) to gain an understanding of the difference between the two. If you define this, you must define two other OG basic properties as well: `type` and `image`. ([Learn more.](https://ogp.me/#metadata))
openGraph.basic.type | string | Set the [type](https://ogp.me/#types) Open Graph should use. If you define this, you must define two other OG basic properties as well: `title` and `image`. ([Learn more.](https://ogp.me/#metadata))
openGraph.basic.image | string | URL of the image that should be used in social media previews. If you define this, you must define two other OG basic properties as well: `title` and `type`. ([Learn more.](https://ogp.me/#metadata))
openGraph.basic.url | string | The canonical URL of your object that will be used as its permanent ID in the graph. Most likely either the url of the page or its canonical url (see above). If you define this, you must define the other 3 OG basic properties as well: `title`, `type` and `image`. ([Learn more.](https://ogp.me/#metadata)). If you define the other 3 OG basic properties but don't define this, `Astro.request.canonicalURL.href` will be used as the default value.
openGraph.basic.url | string | The canonical URL of your object that will be used as its permanent ID in the graph. Most likely either the url of the page or its canonical url (see above). If you define this, you must define the other 3 OG basic properties as well: `title`, `type` and `image`. ([Learn more.](https://ogp.me/#metadata)). If you define the other 3 OG basic properties but don't define this, `Astro.canonicalURL.href` will be used as the default value.
openGraph.optional.audio | string | A URL to an audio file to accompany this object.
openGraph.optional.description | string | A one to two sentence description of your object.
openGraph.optional.determiner | string | The word that appears before this object's title in a sentence. An enum of (a, an, the, "", auto). If auto is chosen, the consumer of your data should chose between "a" or "an". Default is "" (blank).
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/seo.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe("Basic Tags Without URL", () => {
);
});

it("The Open Graph Url property defaults to Astro.request.canonicalURL.href", () => {
it("The Open Graph Url property defaults to Astro.canonicalURL.href", () => {
cy.get('head meta[property="og:url"]').should(
"have.attr",
"content",
Expand Down
2 changes: 1 addition & 1 deletion src/SEO.astro
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ validateProps(props);

{title ? <title>{title}</title> : null}

<link rel="canonical" href={canonical || Astro.request.canonicalURL.href} />
<link rel="canonical" href={canonical || Astro.canonicalURL.href} />

{description ? <meta name="description" content={description} /> : null}

Expand Down
2 changes: 1 addition & 1 deletion src/components/OpenGraphBasicTags.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ const { openGraph } = Astro.props;
<meta property="og:title" content={openGraph.basic.title} />
<meta property="og:type" content={openGraph.basic.type} />
<meta property="og:image" content={openGraph.basic.image} />
<meta property="og:url" content={openGraph.basic.url || Astro.request.canonicalURL.href} />
<meta property="og:url" content={openGraph.basic.url || Astro.canonicalURL.href} />