If I have desktop and mobile versions of the website how to avoid duplicate content?

on the desktop version like this:
<link rel="alternate" media="only screen and (max-width: 640px)" href="https://сайт.ru/mobile/index.php" />


on mobile so:
<link rel="canonical" href="https://сайт.ru/index.php" />


How to avoid duplicate content? have the same title, description, h1 to prescribe two versions?
April 7th 20 at 15:26
2 answers
April 7th 20 at 15:28
Canonical already well should be. In robots.txt maybe just specify Disallow: /mobile/ ?
April 7th 20 at 15:30
You have a content everywhere the same?
Yes, almost all the same - Destin_Schmidt commented on April 7th 20 at 15:33

Find more questions by tags Search engine optimization