How canI fetch the taxonomy details from the uuid or from taxonomy alias. My url looks like


which is a search result page and is a view output. Here I want to add meta tags if the job category is enabled which is a taxonomy term. I have added the meta tags from back end. For this I am trying to update template_preprocess_html to inject meta tags.

But I can't get the taxonomy details since there is no direct way to fetch tid. Please let me know if there is any way to get the details from job category uuid or from taxonomy alias.


You can get taxonomy ID from path alias like below.

$path = \Drupal::service('path.alias_manager')->getPathByAlias('YOUR ALIAS PATH');
$explode = explode('/',$path);
$tid = $explode[3];

You can also replace "taxonomy/term/" with the empty value (str_replace) and get tid.

After getting TID from path alias you can get details of taxonomy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy