SSG with fallback doesn't generate AMP page dynamically
See original GitHub issueBug report
Describe the bug
- When SSG with
fallback: true
andamp: "hybrid"
are used together, the paths not specified ingetStaticPaths
have an invalid href in<link rel="amphtml">
tag.- For example, when there is a
pages/[slug].jsx
and the user visits/bar
, the<link rel="amphtml">
tag will refer to/[slug].amp
.
- For example, when there is a
To Reproduce
https://github.com/wawoon/next-amp-ssg-fallback-reproduce
pages/[slug]/index.jsx
export default (props) => {
return <div>slug: {props.slug}</div>;
};
export const config = {
amp: "hybrid",
};
export const getStaticProps = async (ctx) => {
return {
props: {
slug: ctx.params.slug,
},
};
};
export const getStaticPaths = async () => {
return { paths: [{ params: { slug: "foo" } }], fallback: true };
};
※ caution: When you add unstable_revalidate
to getStaticProps, the href of <link rel="amphtml">
is overwritten while regeneration by #14251
When the user visits http://localhost:3000/bar
, bar
is not specified in getStaticPaths
, the href of <link rel="amphtml">
refers to /[slug].amp
. And this /[slug].amp
is invalid url.
Expected behavior
- The
/bar
should have correct amp page path, even when the path is not included ingetStaticPaths
. - The amp version of
/bar
should be generated usinggetStaticProps
dynamically.
Screenshots
System information
- macOS
- Chrome
- Next: 9.4.5-canary.12
- Node: v12.14.1
Additional context
- I have recently created #14251 which is related with amp page with SSG.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Incremental Static Regeneration - Data Fetching - Next.js
Learn how to create or update static pages at runtime with Incremental Static ... pages // on-demand if the path doesn't exist. return...
Read more >Server Side Render Dynamic Page based on Route Param
The purpose of the function getStaticPaths is to generate a list of paths for which static HTML will be rendered at build time....
Read more >How to Create Pages in Next.js with Static & Dynamic Data
Step 2: Using getStaticProps to statically generate a page with dynamic data. Next up is getStaticProps and statically compiling our page.
Read more >Documentation: <amp-bind> - amp.dev
For performance, and to avoid the risk of unexpected content jumping, amp-bind does not evaluate expressions on page load. This means visual elements...
Read more >Remix vs Next.js - Bejamas
That would mean having to generate every page at build time ... Although Remix doesn't support SSG, the Remix team suggests using HTTP ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Timer I’m using
fallback: 'blocking'
, withNext@10
, still has the same problem, it doesn’t revalidate.AMP will require you use
fallback: 'unstable_blocking'
, maybe we can toggle this by default for AMP pages!