0

I'm trying to find out how to set a canonical url on certen pages/articles on a drupal 8 installation. Metatag module, have the option for setting the canonical URL but is a general setting not specific for every page/article.

Does anybody know how to solve this?

Thank you!

2 Answers 2

2

If you want to set a specific canonical URL for a given node, just edit your node and uncheck "Generate automatic URL alias" in the URL alias section and you'll be able to write your own URL.

You might need Path module to be enabled to do that.

If you want to have specific automatic patterns for your URL alias depending on the type of node, then you will need the module Pathauto (https://www.drupal.org/project/pathauto) ; just enable it and configure your patterns for each type of node

2
  • Thank you for your MacSim for your answer, can you also answer me please if the solution you provide creates the <link rel="canonical" href="website.com/page" /> in the head section? Thank you!!
    – nikomaxia
    Commented Oct 16, 2020 at 10:27
  • Drupal core adds it automatically
    – MacSim
    Commented Oct 16, 2020 at 21:42
0

A friend suggest me the follow solution which works perfect!

https://www.drupal.org/docs/8/modules/metatag/standard-usage-scenario

To adjust metatags for a specific entity, the Metatag field must be added first. Follow these steps:

"Go to the "Manage fields" of the entity type. Select "Meta tags" from the "Add a new field" selector. Fill in a label for the field, e.g. "Meta tags", and set an appropriate machine name, e.g. "meta_tags". Click the "Save and continue" button. If the site supports multiple languages, and translations have been enabled for this entity, select "Users may translate this field" to use Drupal's translation system."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.