问题
When I build the app, it only creates routes for products already in the database. When I add new products those links aren't automatically added to the routes, and aren't SEO compatible. I have to rebuild the app to "pick up" the new products. Is there a better way of doing this?
回答1:
There's really only 3 options here.
Option 1: Rebuild the app
This is what you're already doing, so I won't touch base on it more, other than point out this only works for static generations.
However, SEO crawlers are getting to the point where they can wait for JS to load, so this can be SEO friendly sometimes. If you're okay with that, then you can just run in SPA mode and fetch the products client side.
Option 2: Server Side Rendering
When using Nuxt in universal mode, you can fetch and render the product data server side, either using the fetch or async data API's. Products can be added to a database or CMS, and immediately be usable by the app.
Content rendered this way is SEO friendly as the HTML is rendered server side, provided you also remember to update the meta values with the correct titles/descriptions.
I'd say this is the best option for large amounts of indexable content, but unfortunately requires a server to be run to host the app.
Option 3: Pre rendering
You can use a 3rd party service, like enter link description here, which will handle pre-running your app for SEO services. However, it's not free, and so I'd say this is ultimately the worst.
来源:https://stackoverflow.com/questions/63061720/using-nuxt-with-seo-compatibility-for-thousands-of-products