Closed paulroemer closed 2 months ago
Another solution: Make sure the correct canonical is set with the help of an index boot strap listener.
Investigated this and these should be replaced in HtmlHeaderController.java with the correct URL:
<link rel="canonical" href="https://vaadin.com/directory/component/moneyfield">
However, the problem seems to be the version number that might lead to situation when the replace does not happen correctly.
To test run:
curl https://vaadin.com/directory/component/moneyfield
curl https://vaadin.com/directory/component/moneyfield/1.0.0
Deployed. Verified that also curl https://vaadin.com/directory/component/moneyfield/1.0.0
now correctly returns <link rel="canonical" href="https://vaadin.com/directory/component/moneyfield">
.
Looks like Google picks up the first canonical link it finds and does not wait for /directory to update it. Generic canonical link is set here: https://github.com/vaadin/directory/blob/main/frontend/index.html#L8
Result is:
If you check the page when the DOM is fully loaded, the canonical link is correct (i.e. it was updated as expected).
Solution: Do not set the generic canonical link in the index.html. Even if Google cannot find any canonical link after the removal anymore, it is still better to have no instead of a wrong canonical link.