drupal 8 get taxonomy terms by vocabulary name

To get taxonomy terms by vocabulary name in Drupal 8, you can use the following code:

// Load the taxonomy vocabulary by name.
$vid = \Drupal::entityQuery('taxonomy_vocabulary')
  ->condition('name', 'your_vocabulary_name')
  ->execute();

// Load the taxonomy terms using the vocabulary ID.
$terms = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);

// Loop through the terms and print their names.
foreach ($terms as $term) {
  $term_name = $term->name->value;
  // Do something with the term name.
}

Replace 'your_vocabulary_name' with the actual name of the vocabulary you want to retrieve terms from. This code will load the taxonomy vocabulary by name and then use the vocabulary ID to load the corresponding taxonomy terms. You can then iterate through the terms and perform any desired actions with their names or other properties.

Make sure to include this code in a custom module or in a custom block or page template, depending on your specific use case.