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(seo): Fix undefined host in canonical tags of product pages #814

Merged
merged 1 commit into from
Jul 9, 2021

Conversation

tlgimenes
Copy link
Contributor

@tlgimenes tlgimenes commented Jul 8, 2021

What's the purpose of this pull request?

While SSR, we generated canonical tags with the SSR host. The SSR host was undefined which made us to generate canonical link tags like:
https://undefined/<pathname>

To prevent this problem, we generate relative canonical tags with /<pathname> during SSR and hydrate it with https://<host>/<pathname> once the React hydration kicks in.

With this I hope to solve the problem of product pages having invalid canonicals.

You may be wondering now why don't we just fix the host value during SSR to the same domain as we are going to serve the production server. The response to this question is that we use lighthouse to test these urls in a different domain, and if lighthouse sees that the canonical points to a different domain, it will break with an error. To circumvent this issue we do this hydration strategy

How to test it?

https://github.com/vtex-sites/btglobal.store/pull/706
https://github.com/vtex-sites/marinbrasil.store/pull/549
https://github.com/vtex-sites/storecomponents.store/pull/1019

@netlify
Copy link

netlify bot commented Jul 8, 2021

✔️ Deploy Preview for storeui ready!

🔨 Explore the source changes: 06daf69

🔍 Inspect the deploy log: https://app.netlify.com/sites/storeui/deploys/60e77403fa01d00007e2891c

😎 Browse the preview: https://deploy-preview-814--storeui.netlify.app

@tlgimenes tlgimenes changed the title fix(seo): Remove host from SSR fix(seo): Fix undefined host in canonical tags of product pages Jul 8, 2021
@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 8, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 06daf69:

Sandbox Source
Store UI Typescript Configuration

@tlgimenes tlgimenes marked this pull request as ready for review July 8, 2021 22:11
@tlgimenes tlgimenes requested a review from a team as a code owner July 8, 2021 22:11
@tlgimenes tlgimenes merged commit 3ba980d into master Jul 9, 2021
@tlgimenes tlgimenes deleted the fix/product-seo branch July 9, 2021 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants