I have a search results view from Search API where I need to use the excerpt that highlights the keywords being searched. In this instance, that prevents me from using a view mode output as the result.

In this instance, I have a view set up to output title, URI, date modified and search excerpt. I have a decent bit of theming to do around the form and results, but I can't seem to figure out how to view both the template suggestions for each view field, or just theme it manually in the given template views-view--unformatted--search--results.html.twig.

I also tried {{ kint(row) }} and even when viewing on its own page, basically locked up my browser.

So for instance, for the title, I need the markup to be:

<a href="#" class="search-result__item-title">Foo Exam</a>

For consistency reasons, I would like to control it from twig templates instead of attempt to do it in the views admin (setting label field etc settings).


1 Answer 1


You're probably looking for



In your view click on your title field and uncheck Link to the content.

then your template file

<a href="#" class="search-result__item-title">{{ fields.title.content }}</a>

Not really sure if you really want # as href. I think you want to link to content. So add Path as a field.

<a href="{{ fields.path.content }}" class="search-result__item-title">{{ fields.title.content|striptags }}</a>

Note: You'll probably want to use |striptags if you do not strip the markup from the views UI. Unless you do not mind having <divs> wrapping your title text.

then {{ fields.field_machine_name.content }} each of the rest of your fields that you want to output.

Important: Make sure TWIG DEBUG is off, as it tends to screw up templates in Views.

  • Yeah the # is just from the prototype.
    – Kevin
    Jan 24, 2017 at 0:47
  • How do I find out what the machine name would be for just the node title? title by itself does not work.
    – Kevin
    Jan 24, 2017 at 14:33
  • In content type Manage Display, there is a Machine Name column, you can check there. But... the machine name should be title, unless you somehow changed it... Oh also check that you're not hiding this field from display in the Views UI.
    – No Sssweat
    Jan 24, 2017 at 14:36
  • Yes. Also, fields.path.content doesn't work. This data is coming out of Search API + Search API Solr.
    – Kevin
    Jan 24, 2017 at 14:39
  • @Kevin interesting, if you do a Rewrite Results on your title field throught the Views Field UI, for available replacement patterns what do you get?
    – No Sssweat
    Jan 24, 2017 at 14:42

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.