diff --git a/core/lib/Drupal/Core/Render/theme.api.php b/core/lib/Drupal/Core/Render/theme.api.php
index 6e88ed586104cec47751ad4b72c2290bad511678..496d799ca0b02188d3a82e23581471c8a4b8e108 100644
--- a/core/lib/Drupal/Core/Render/theme.api.php
+++ b/core/lib/Drupal/Core/Render/theme.api.php
@@ -1246,6 +1246,8 @@ function hook_page_bottom(array &$page_bottom) {
  *     'module', 'theme_engine', or 'theme'.
  *   - theme path: The directory path of the theme or module. If not defined,
  *     it is determined during the registry process.
+ *   - deprecated: The deprecated key marks a twig template as deprecated with
+ *     a custom message.
  *
  * @see themeable
  * @see hook_theme_registry_alter()
diff --git a/core/lib/Drupal/Core/Theme/ThemeManager.php b/core/lib/Drupal/Core/Theme/ThemeManager.php
index 326a1c34e92bed9609d9bf554421094ac2de7d3e..f3247d6d2f6cc12f950f3194cc9aea6240bf4c1b 100644
--- a/core/lib/Drupal/Core/Theme/ThemeManager.php
+++ b/core/lib/Drupal/Core/Theme/ThemeManager.php
@@ -182,6 +182,9 @@ public function render($hook, array $variables) {
     }
 
     $info = $theme_registry->get($hook);
+    if (isset($info['deprecated'])) {
+      @trigger_error($info['deprecated'], E_USER_DEPRECATED);
+    }
 
     // If a renderable array is passed as $variables, then set $variables to
     // the arguments expected by the theme function.
diff --git a/core/modules/system/tests/modules/deprecated_twig_template/deprecated_twig_template.info.yml b/core/modules/system/tests/modules/deprecated_twig_template/deprecated_twig_template.info.yml
new file mode 100644
index 0000000000000000000000000000000000000000..9670c364aa445a6cbccff0028dccf88ab69ad432
--- /dev/null
+++ b/core/modules/system/tests/modules/deprecated_twig_template/deprecated_twig_template.info.yml
@@ -0,0 +1,5 @@
+name: 'Deprecated Twig Template Test'
+type: module
+description: 'Provides a deprecated Twig template for testing purposes.'
+package: Testing
+version: VERSION
diff --git a/core/modules/system/tests/modules/deprecated_twig_template/deprecated_twig_template.module b/core/modules/system/tests/modules/deprecated_twig_template/deprecated_twig_template.module
new file mode 100644
index 0000000000000000000000000000000000000000..6d001c6b4f3fc34d4db75c0b74e118c14f76c594
--- /dev/null
+++ b/core/modules/system/tests/modules/deprecated_twig_template/deprecated_twig_template.module
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * @file
+ * This is a test module for deprecated twig templates.
+ */
+
+/**
+ * Implements hook_theme().
+ */
+function deprecated_twig_template_theme() {
+  return [
+    'deprecated_template' => [
+      'variables' => [
+        'message' => NULL,
+      ],
+      'deprecated' => 'The "deprecated-template.html.twig" template is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another template instead. See https://www.example.com',
+    ],
+  ];
+}
diff --git a/core/modules/system/tests/modules/deprecated_twig_template/deprecated_twig_template.routing.yml b/core/modules/system/tests/modules/deprecated_twig_template/deprecated_twig_template.routing.yml
new file mode 100644
index 0000000000000000000000000000000000000000..fd951df98a0d4379a1cebc87a6f2c02a615d60a1
--- /dev/null
+++ b/core/modules/system/tests/modules/deprecated_twig_template/deprecated_twig_template.routing.yml
@@ -0,0 +1,6 @@
+deprecated_twig_template:
+  path: '/deprecated-twig-template'
+  defaults:
+    _controller: '\Drupal\deprecated_twig_template\Controller\DeprecatedTwigTemplateController::deprecatedTwigTemplate'
+  requirements:
+    _access: 'TRUE'
diff --git a/core/modules/system/tests/modules/deprecated_twig_template/src/Controller/DeprecatedTwigTemplateController.php b/core/modules/system/tests/modules/deprecated_twig_template/src/Controller/DeprecatedTwigTemplateController.php
new file mode 100644
index 0000000000000000000000000000000000000000..acdfea966c78866166084edb9b2153c852eed083
--- /dev/null
+++ b/core/modules/system/tests/modules/deprecated_twig_template/src/Controller/DeprecatedTwigTemplateController.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Drupal\deprecated_twig_template\Controller;
+
+use Drupal\Core\Controller\ControllerBase;
+
+/**
+ * Controller for calling a deprecated theme.
+ */
+class DeprecatedTwigTemplateController extends ControllerBase {
+
+  /**
+   * Display the deprecated template with a message.
+   *
+   * @return array
+   *   Render array containing the deprecated template.
+   */
+  public function deprecatedTwigTemplate() {
+    return [
+      '#theme' => 'deprecated_template',
+      '#message' => 'This is a deprecated template. Use an alternative template.',
+    ];
+  }
+
+}
diff --git a/core/modules/system/tests/modules/deprecated_twig_template/templates/deprecated-template.html.twig b/core/modules/system/tests/modules/deprecated_twig_template/templates/deprecated-template.html.twig
new file mode 100644
index 0000000000000000000000000000000000000000..7c2ca0047cddfe7f21fdb4d72cbb9d7389dc4a0b
--- /dev/null
+++ b/core/modules/system/tests/modules/deprecated_twig_template/templates/deprecated-template.html.twig
@@ -0,0 +1,3 @@
+<div class="deprecated-template">
+  {{ message }}
+</div>
diff --git a/core/modules/system/tests/src/Functional/Module/DeprecatedTemplateTest.php b/core/modules/system/tests/src/Functional/Module/DeprecatedTemplateTest.php
new file mode 100644
index 0000000000000000000000000000000000000000..24dff44e28162f85797a8185be54fb5a4766331d
--- /dev/null
+++ b/core/modules/system/tests/src/Functional/Module/DeprecatedTemplateTest.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Drupal\Tests\system\Functional\Module;
+
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Tests that the deprecated template is correctly marked.
+ *
+ * @group Theme
+ */
+class DeprecatedTemplateTest extends BrowserTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  protected $defaultTheme = 'stark';
+
+  /**
+   * Modules to install.
+   *
+   * @var array
+   */
+  protected static $modules = ['deprecated_twig_template'];
+
+  /**
+   * Tests that the deprecated template is marked as deprecated.
+   *
+   * @group legacy
+   */
+  public function testDeprecatedTemplate() {
+    $this->expectDeprecation('The "deprecated-template.html.twig" template is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another template instead. See https://www.example.com');
+    $this->drupalGet('/deprecated-twig-template');
+  }
+
+}