diff --git a/src/Plugin/Block/OpenfedSocialBlock.php b/src/Plugin/Block/OpenfedSocialBlock.php
index c9b6dd5..318543e 100644
--- a/src/Plugin/Block/OpenfedSocialBlock.php
+++ b/src/Plugin/Block/OpenfedSocialBlock.php
@@ -42,9 +42,16 @@ class OpenfedSocialBlock extends BlockBase {
   private function openfed_social_get_icon_links() {
     // Use current page' url and title to complete each share link information.
     $url = Url::fromRoute('<current>', [], ['absolute' => 'true']);
-    $title = \Drupal::service('title_resolver')
-      ->getTitle(\Drupal::request(), \Drupal::routeMatch()->getRouteObject());
-    // Force title to be a string.
+    // Use site name as default title.
+    $title = \Drupal::config('system.site')->get('name');
+    $route_object = \Drupal::routeMatch()->getRouteObject();
+
+    // Grabs the title from the current route.
+    if ($route_object !== NULL) {
+      $title = \Drupal::service('title_resolver')
+        ->getTitle(\Drupal::request(), $route_object);
+    }
+
     $title = is_array($title) ? $title['#markup'] : $title;
 
     // Getting all the enabled social networks, rendering them based on the user
