Score:0

Twig Template - Div Element Being Inserted in Link URL

pe flag

I have a link field type that I'm referencing in a Twig template. I'm using this code:

<div class="outlined">
<a href="{{content.field_3_column_image_link}}">{{content.field_3_column_image}}</a>
</div>

...BUT when I hover over the link I am seeing https://nameofsite/<div>/node/1</div> instead of https://nameofsite/node/1.

Can someone help me figure out why this is happening? Where are these divs coming from?

Thanks! Bryan

pe flag
Yes, thank you! {{content.field_3_column_image_link.0}} did the trick and stripped out the divs!
Score:1
pe flag

See the comment from Patrick Kenny; the link he referred me to had the answer: I just had to use this insted: {{content.field_3_column_image_link.0}}.

Apparently the .0 at the end of the filed type name strips out everything but the raw value.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.