3

Very simply put, I want to print the plain text from the title field of my node without any additional html. Currently I have this in my node--custom-template.html.twig file

<h3 class="fancy">
      {{ label }}      
</h3>

but it outputs it like this

<h3 class="fancy">
          <span data-quickedit-field-id="node/13/title/en/teaser">My Title</span>      
</h3>

I'd like it like this

<h3 class="fancy">My Title</h3>

I've tried using some of the twig filters like |striptags and |raw, but then nothing displays. I'm wondering if there is a template I could edit for this field, or any other way to just get the plain text string of the node title.

9

You can get the unformatted title from the node object:

{{ node.label  }}
  • I also discovered that if you need more control over how the title displays you can use the twig template field--node--title.html.twig - just another option. – flamesquirrel Dec 5 '16 at 9:00

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.