generateMetadata: how to use <link rel="amphtml" .... /> tag? #51496
Unanswered
a4lmamun
asked this question in
App Router
Replies: 2 comments 1 reply
-
Hi, @a4lmamun, I've found a crutch solution to add export async function generateMetadata({ params }): Promise<Metadata> {
return {
icons: {
other: {
rel: "amphtml",
url: `${YOUR_SITE_HOST}/amp/${params.slug.join('/')}`
}
}
}
} The result template: <link rel="amphtml" href="https://example.com/amp/articles/bla/bla/bla/23"> Full gist |
Beta Was this translation helpful? Give feedback.
1 reply
-
code shared by @KamilOcean is fine for single rel but If we have to add multiple rel link we case use following configuration in generateMetadata export async function generateMetadata({ params }): Promise<Metadata> {
return {
icons: {
icon: [
{
rel: "amphtml",
url: `${YOUR_SITE_HOST}/amp/${params.slug.join('/')}`
},
{
rel: "next",
url: ``${YOUR_SITE_HOST}/amp/${nextpageurl}``
},
{
rel: "prev",
url: `${YOUR_SITE_HOST}/amp/${prevpageurl}`
},
]
}
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Need a way to use amphtml link rel tag to achieve
<link rel="amphtml" href="" />
.Reference:
https://amp.dev/documentation/guides-and-tutorials/optimize-and-measure/discovery
Add the following to the non-AMP page:
<link rel="amphtml" href="https://www.example.com/url/to/amp/document.html">
And this to the AMP page:
<link rel="canonical" href="https://www.example.com/url/to/full/document.html”>
Beta Was this translation helpful? Give feedback.
All reactions