diff --git a/tests/src/Kernel/UnitTest.php b/tests/src/Kernel/UnitTest.php
index f520011..c91f194 100644
--- a/tests/src/Kernel/UnitTest.php
+++ b/tests/src/Kernel/UnitTest.php
@@ -106,4 +106,14 @@ class UnitTest extends KernelTestBase {
       $this->assertEqual($invalid_tokens, $test['invalid tokens'], 'Invalid tokens detected properly: ' . implode(', ', $invalid_tokens));
     }
   }
+
+  /**
+   * Test that tokens are generated only for content entities.
+   */
+  public function testContentEntityOnlyTokens() {
+    // Verify that type and token info for a config entity is not generated.
+    $this->assertNull($this->tokenService->getTokenInfo('user_role', 'original'));
+    $this->assertNull($this->tokenService->getTokenInfo('user_role', 'url'));
+    $this->assertNull($this->tokenService->getTypeInfo('user_role'));
+  }
 }
diff --git a/token.tokens.inc b/token.tokens.inc
index 717fad8..03a32c5 100644
--- a/token.tokens.inc
+++ b/token.tokens.inc
@@ -20,6 +20,7 @@ use Drupal\menu_link_content\MenuLinkContentInterface;
 use Drupal\system\Entity\Menu;
 use Drupal\user\UserInterface;
 use Symfony\Cmf\Component\Routing\RouteObjectInterface;
+use Drupal\Core\Entity\ContentEntityTypeInterface;
 
 /**
  * Implements hook_token_info_alter().
@@ -63,8 +64,9 @@ function token_token_info_alter(&$info) {
   // Add [token:url] tokens for any URI-able entities.
   $entities = \Drupal::entityTypeManager()->getDefinitions();
   foreach ($entities as $entity => $entity_info) {
-    /* @var \Drupal\Core\Entity\EntityType $entity_info */
-    if (!$entity_info->get('token_type')) {
+    // Do not generate tokens if the entity doesn't define a token type or is
+    // not a content entity.
+    if (!$entity_info->get('token_type') || (!$entity_info instanceof ContentEntityTypeInterface)) {
       continue;
     }
 
