vaadin / directory

Directory 4 Vaadin
Apache License 2.0
1 stars 1 forks source link

Do not set generic canonical link in index.html #70

Closed paulroemer closed 2 months ago

paulroemer commented 2 months ago

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: URL Inspection 2024-07-04 at 11 56 34 AM

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.

paulroemer commented 2 months ago

Another solution: Make sure the correct canonical is set with the help of an index boot strap listener.

samie commented 2 months ago

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
samie commented 2 months ago

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">.