How to modify the value of a taxonomy field of a node using hook_node_view()? I'm using Drupal 8 and I have a taxonomy field in a content type. I have created a node and added the term reference value to this node. Now the node shows up the link to the term. 

I want to show value of the text field added in that taxonomy instead of link to the term.

I want to use this hook and set the value of the term field via code.

function hook_node_view(array &amp;$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) { }
You don't have to use the node view hook. It can be achieved using a taxonomy display as well.

Here is how to do it:


Navigate to "Administration / Structure / Display modes / View modes"
Scroll down to "Taxonomy term"
Add a new Taxonomy term view mode by clicking the according link and giving it a name
Now head to the display settings of your Taxonomy at "Administration / Structure / Taxonomy / [Your vocabulary] / Manage display"
Find the "Custom display settings" tab, tick your newly created view mode and save
A new tab with the name of your view mode will appear, where you can just add the field you like to display and disable all others; save again
Head to the manage display settings of your content type that features the entity reference field to this taxonomy at "Administration / Structure / Content types / [Your content type] / Manage display"
Find your entity reference field and switch "Format" to "Rendered entity"
Using the cogwheel at the very right, you can now choose your above created view mode for how to render the referenced taxonomy entity


Save and you have the rendered field of your taxonomy shown at the node page.

PS.: The above procedure can be used for many other referenced entities as well and does not require any custom programming.