-
Notifications
You must be signed in to change notification settings - Fork 212
@W-17643479@ Add page meta data to search results and product pages #2232
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
Changes from 4 commits
eb7121f
73a2622
5af8ab4
0bdded1
5bc9c77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -99,7 +99,8 @@ const ProductDetail = () => { | |||||||||||||||||||||||||||||||||
| 'prices', | ||||||||||||||||||||||||||||||||||
| 'variations', | ||||||||||||||||||||||||||||||||||
| 'set_products', | ||||||||||||||||||||||||||||||||||
| 'bundled_products' | ||||||||||||||||||||||||||||||||||
| 'bundled_products', | ||||||||||||||||||||||||||||||||||
| 'page_meta_tags' | ||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||
| allImages: true | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
@@ -455,7 +456,17 @@ const ProductDetail = () => { | |||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||
| <Helmet> | ||||||||||||||||||||||||||||||||||
| <title>{product?.pageTitle}</title> | ||||||||||||||||||||||||||||||||||
| <meta name="description" content={product?.pageDescription} /> | ||||||||||||||||||||||||||||||||||
| {product?.pageMetaTags ? ( | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| {product?.pageMetaTags ? ( | |
| {product?.pageMetaTags?.length ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, I think we should also consider the scenario where the pageMetaTags does not include a description key. In that case, the code will fall back to using the pageDescription.
| {product?.pageMetaTags ? ( | |
| // description is one of the page meta tags returned for products | |
| // and this is the same as product?.pageDescription | |
| product.pageMetaTags?.map((pageMetaTag) => { | |
| const name = pageMetaTag.id | |
| const content = pageMetaTag.value | |
| return <meta name={name} content={content} key={name} /> | |
| }) | |
| ) : ( | |
| <meta name="description" content={product?.pageDescription} /> | |
| {product?.pageMetaTags?.length > 0 && product.pageMetaTags.map(({ id, value }) => ( | |
| <meta name={id} content={value} key={id} /> | |
| ))} | |
| {/* Fallback for description if not included in pageMetaTags */} | |
| {!product?.pageMetaTags?.some(tag => tag.id === 'description') && product?.pageDescription && ( | |
| <meta name="description" content={product.pageDescription} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that the description meta tag is generated from the product description so they will always be the same value. But I can add this fallback just in case.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the meta title be consistent with the content of the
<title>tag, or default toproduct.pageTitleif the meta title is not provided?pwa-kit/packages/template-retail-react-app/app/pages/product-detail/index.jsx
Line 458 in eb7121f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike with description, the title meta tag and page title do appear to be different. (It seems that the title meta tag is generated based on the page title, the price, and the site id?)
I think using the page title as the title is more straightforward as what you enter in BM is what you'll get with no extras added.