How to define specific page on hook_page_top? I want to add some stuff to the top of the page on certain pages.

How can I specify which pages that my custom content should be included on?
You can use the request object to figure out what page you are on and what to do with it.

Fx

$uri = \Drupal::request()-&gt;getRequestUri();


Maybe you want to get the route name instead:

$route = \Drupal::routeMatch()-&gt;getRouteName();


From there it's just a matter of defining your conditions in the hook.