I've create views as block. Then i tried to theme my views block by altering block--views-block-html.twig file. I've struggled to get views machine name in this file. I need views machine name for some reason. So any other solutions to get views machine name?


Views machine name would be: /admin/structure/views/view/frontpage.

You can edit/change the view name on right corner: Edit view name / description.

You can override the template name using below.

  • [base template name]--[view machine name]--[view display id].html.twig
  • [base template name]--[view machine name]--[view display type].html.twig

So this would be:

  • views-view--frontpage--page.html.twig


  • views-view--frontpage--block.html.twig

There is no theme information is displayed with D8 views as D7 views was having the those information.

Please refer the reference page.

  • Yes i know this. But i want to get views machine name inside the block--views-block-html.twig file
    – Guru
    Jan 21 '16 at 5:34
  • Please refer updated answer.
    – Kalpan
    Jan 21 '16 at 6:05
  • You lead me to choose theme file. Please read question carefully. I want to know how to get views machine name inside block--views-block-html.twig file.
    – Guru
    Jan 21 '16 at 6:58

You should be able to access the ID with:


...but to do that, you need to preprocess the block/view; in my case, I needed to grab the machine name of a view that I was preprocessing using template_chn_preprocess_views_view().

See the other options/methods you can access inside ViewExecutable.

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.