1

I have a news content type, and the node--news.html.twig template.

I have some fields, but I can not create links to node for text-field from teaser-view. How can I achieve this?

5

Node templates have url variable which you can use in your template in the following way:

<a href="{{ url }}">{{ label }}</a>

(See node.html.twig for an example.)

In general, you can use link function in twig template:

{{ link(item.title, item.url, { 'class':['foo', 'bar', 'baz']} ) }}

(See Functions - In Twig Templates for a short list of twig functions provided by Drupal. Also take a look at TwigExtension for their source.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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