- Guides & Documentation
Knowledgebase
Featured articles, how-to guides and quick tips.
Get URL (or Title) from Link field in Drupal - Twig
You might be using a link field on your entity type, and if so, you might find yourself in a position where you require the exact URL from the link reference field.
Stick this in your template file and you're good to go:
{{ content.field_custom_link.0['#url'] }}
If you need the title, use this instead:
{{ content.field_custom_link.0['#title'] }}
Be sure to switch out the bolded text above for the machine name of your custom link field.