Thing is, page.html.twig
probably is the second-worst template to do this kind of stuff (headed by html.html.twig
and followed by node.html.twig
). Instead you'd better do this on the field-level.
Template Suggestions
But first of all, it's really important that you enable Twig debugging. Simply follow: Debugging Twig templates. From now on you will get template suggestions printed as HTML comments into your markup. See the sample output for my "Article" content type's body field:
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'field' -->
<!-- FILE NAME SUGGESTIONS:
* field--node--body--article.html.twig
* field--node--body.html.twig
* field--node--article.html.twig
* field--body.html.twig
x field--text-with-summary.html.twig
* field.html.twig
-->
<!-- BEGIN OUTPUT from 'core/themes/classy/templates/field/field--text-with-summary.html.twig' -->
<div property="schema:text" data-quickedit-field-id="node/1/body/en/teaser" class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item quickedit-field"><p>Elitphas sellus laoreet consequa laoreetc maecenas aesent iam ras fames. Volutpat sacras feugiatm hendre lacusp esent quamsusp uada netus. Duinulla sque teger justop justov metiam. Uisque vestibu tcras pretium llam lum llam. Consec ctetur llaut necinte magnap vel proin. Justo teger sedinteg vulput ligula arcu litora telluss eger. Roin massan quamnull nibh vitaenu sduis felis rproin ndisse. Ipsumves nullap teger mussed condim sacras.</p></div>
<!-- END OUTPUT from 'core/themes/classy/templates/field/field--text-with-summary.html.twig' -->
The little x
in front of the listed templates indicates which templates is currently in use. And just on top of the actual field output the relative path on your hard drive to the current template file is printed. Now you could go, copy this template, paste it into your theme's templates
, and rename it along one of the commented suggestions. Probably as distinct as possible.
So in your case that would be:
field--node--field-newsdesk-and-press--press-release.html.twig
field--node--field-newsdesk-and-press--interview.html.twig
And inside there you edit the markup to fit your needs. Via hook_theme_suggestions_HOOK_alter
the existing template suggestions also could easily be extended to respect the view mode as well.
Still, this isn't the ideal solution in my own opinion (though it's widely done that way). Managing a lot of templates can become fiddly really fast. Plus: the actual Field UI in the back-end becomes more and more useless.
I'd recommend to programmatically create two pseudo fields instead which simply can be placed in each node type's Manage Display settings. Or to do this entirely inside preprocess functions, again programmatically. But this would go far beyond the scope of your question and should better be asked separately if you don't get it done yourself.