Short snippet that shows how to get url parameters in drupal 8. Where in drupal 7 you would have to do some $_GET or work with args(0), you now have a clean function to do this.

$tag = \Drupal::request()->query->get('tag'); 

// Then you can proceed with 
if($tag) {


Saved you some valuable time?

Donate and get more free time-saving code on this website in the future.