On fresh install and activation of the AMP Base theme, an error is thrown, that the "amp-skip-link.html.twig" couldn't be found.

Steps to reproduce:

  1. Install AMP and AMPtheme
  2. use "AMP Base" as AMP theme
  3. Activate AMP for a Content Type
  4. Create a new content of this type and go to its amp page by adding "?amp" to the URL
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tjwelde created an issue. See original summary.

tjwelde’s picture

Project: Accelerated Mobile Pages (AMP) » AMP Theme
tjwelde’s picture

FileSize
391 bytes

Drupal apparently only searches through theme templates for overrides. Since "amp_skip_link" is defined within the theme itself, it only looks in the root of templates. This patch adds the correct path to the render array definition.

Jaypan’s picture

Status: Active » Reviewed & tested by the community

I had the same error, and this patch fixed it.

floown’s picture

Hello,

I had the same error in Apache logs:
[Thu Dec 28 20:42:04.251806 2017] [php7:notice] [pid 31123] [client 163.170.105.159:54426] Uncaught PHP Exception Twig_Error_Loader: "Template "themes/contrib/amptheme/amptheme/templates/amp-skip-link.html.twig" is not defined (Drupal\\Core\\Template\\Loader\\ThemeRegistryLoader: Unable to find template "themes/contrib/amptheme/amptheme/templates/amp-skip-link.html.twig" in the Drupal theme registry.)." at /home/admin/web/dev.domain.com/public_html/web/themes/contrib/amptheme/amptheme/templates/layout/html.html.twig line 42

I have apply the patch:

~/web/dev.domain.com/public_html/web/themes/contrib/amptheme/amptheme/ patch < amp_skip_link_-2848068-3.patch
patching file amptheme.theme

but now I have:
[Thu Dec 28 20:42:31.946241 2017] [php7:notice] [pid 31121] [client 163.170.105.159:54428] Error: Call to a member function attributes() on boolean in /home/admin/web/dev.domain.com/public_html/web/themes/contrib/amptheme/amptheme/amptheme.theme on line 221 #0 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Theme/ThemeManager.php(287): amptheme_preprocess_block(Array, 'block', Array)\n#1 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(437): Drupal\\Core\\Theme\\ThemeManager->render('block', Array)\n#2 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(450): Drupal\\Core\\Render\\Renderer->doRender(Array)\n#3 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\\Core\\Render\\Renderer->doRender(Array, false)\n#4 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Template/TwigExtension.php(490): Drupal\\Core\\Render\\Renderer->render(Array)\n#5 /home/admin/web/dev.domain.com/public_html/web/sites/default/files/php/twig/5a4326305fbad_page.html.twig_ff5Femhp1kzM3aTZyDixDPQt-/Jt1QPgj4A7yK08rjpPW8Pjxc7m4juPUImhC1ENrIy8Y.php(47): Drupal\\Core\\Template\\TwigExtension->escapeFilter(Object(Drupal\\Core\\Template\\TwigEnvironment), Array, 'html', NULL, true)\n#6 /home/admin/web/dev.domain.com/public_html/vendor/twig/twig/lib/Twig/Template.php(432): __TwigTemplate_73a5ce60eb7d2a75d4c17b8d72f9de9d902c727a56fb40d6ab87ad44cb9508b2->doDisplay(Array, Array)\n#7 /home/admin/web/dev.domain.com/public_html/vendor/twig/twig/lib/Twig/Template.php(403): Twig_Template->displayWithErrorHandling(Array, Array)\n#8 /home/admin/web/dev.domain.com/public_html/vendor/twig/twig/lib/Twig/Template.php(411): Twig_Template->display(Array)\n#9 /home/admin/web/dev.domain.com/public_html/web/core/themes/engines/twig/twig.engine(64): Twig_Template->render(Array)\n#10 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('themes/contrib/...', Array)\n#11 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(437): Drupal\\Core\\Theme\\ThemeManager->render('page', Array)\n#12 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\\Core\\Render\\Renderer->doRender(Array, false)\n#13 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Template/TwigExtension.php(490): Drupal\\Core\\Render\\Renderer->render(Array)\n#14 /home/admin/web/dev.domain.com/public_html/web/sites/default/files/php/twig/5a4326305fbad_html.html.twig_7eViIFHH4zHZfLSAhM4QF99ct/aPtpbbvmb38QyHrMngOXlQgVF__8PQB8YpxjLn7A094.php(99): Drupal\\Core\\Template\\TwigExtension->escapeFilter(Object(Drupal\\Core\\Template\\TwigEnvironment), Array, 'html', NULL, true)\n#15 /home/admin/web/dev.domain.com/public_html/vendor/twig/twig/lib/Twig/Template.php(432): __TwigTemplate_eb3ca6721f62a910a396a966bb35c1df55ec930d40492f412ad73509542c1454->doDisplay(Array, Array)\n#16 /home/admin/web/dev.domain.com/public_html/vendor/twig/twig/lib/Twig/Template.php(403): Twig_Template->displayWithErrorHandling(Array, Array)\n#17 /home/admin/web/dev.domain.com/public_html/vendor/twig/twig/lib/Twig/Template.php(411): Twig_Template->display(Array)\n#18 /home/admin/web/dev.domain.com/public_html/web/core/themes/engines/twig/twig.engine(64): Twig_Template->render(Array)\n#19 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Theme/ThemeManager.php(384): twig_render_template('themes/contrib/...', Array)\n#20 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(437): Drupal\\Core\\Theme\\ThemeManager->render('html', Array)\n#21 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(195): Drupal\\Core\\Render\\Renderer->doRender(Array, false)\n#22 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(147): Drupal\\Core\\Render\\Renderer->render(Array)\n#23 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Render/Renderer.php(576): Drupal\\Core\\Render\\MainContent\\HtmlRenderer->Drupal\\Core\\Render\\MainContent\\{closure}()\n#24 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/Render/MainContent/HtmlRenderer.php(148): Drupal\\Core\\Render\\Renderer->executeInRenderContext(Object(Drupal\\Core\\Render\\RenderContext), Object(Closure))\n#25 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/EventSubscriber/MainContentViewSubscriber.php(90): Drupal\\Core\\Render\\MainContent\\HtmlRenderer->renderResponse(Array, Object(Symfony\\Component\\HttpFoundation\\Request), Object(Drupal\\Core\\Routing\\CurrentRouteMatch))\n#26 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(108): Drupal\\Core\\EventSubscriber\\MainContentViewSubscriber->onViewRenderArray(Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent), 'kernel.view', Object(Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher))\n#27 /home/admin/web/dev.domain.com/public_html/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\\Component\\EventDispatcher\\ContainerAwareEventDispatcher->dispatch('kernel.view', Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent))\n#28 /home/admin/web/dev.domain.com/public_html/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\\Component\\HttpKernel\\HttpKernel->handleRaw(Object(Symfony\\Component\\HttpFoundation\\Request), 1)\n#29 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\\Component\\HttpKernel\\HttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#30 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\\Core\\StackMiddleware\\Session->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#31 /home/admin/web/dev.domain.com/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(184): Drupal\\Core\\StackMiddleware\\KernelPreHandle->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#32 /home/admin/web/dev.domain.com/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(121): Drupal\\page_cache\\StackMiddleware\\PageCache->fetch(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#33 /home/admin/web/dev.domain.com/public_html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(75): Drupal\\page_cache\\StackMiddleware\\PageCache->lookup(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#34 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47): Drupal\\page_cache\\StackMiddleware\\PageCache->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#35 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(50): Drupal\\Core\\StackMiddleware\\ReverseProxyMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#36 /home/admin/web/dev.domain.com/public_html/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\\Core\\StackMiddleware\\NegotiationMiddleware->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#37 /home/admin/web/dev.domain.com/public_html/web/core/lib/Drupal/Core/DrupalKernel.php(657): Stack\\StackedHttpKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request), 1, true)\n#38 /home/admin/web/dev.domain.com/public_html/web/index.php(19): Drupal\\Core\\DrupalKernel->handle(Object(Symfony\\Component\\HttpFoundation\\Request))\n#39 {main}

I have made a drush cr

When I add ?amp in a url, I have : "The website encountered an unexpected error. Please try again later."

What can I do?

floown’s picture

Status: Reviewed & tested by the community » Active
Jaypan’s picture

Status: Active » Reviewed & tested by the community

That issue is separate from this one, as can be seen from the debug log. It would appear the patch did fix the problem you were having, and now you are having a different problem.

Jon Pugh’s picture

Priority: Normal » Critical

Ran into this. Marking this critical, as it completely breaks the site.

Patch works as expected.

  • KarenS committed 4d35699 on 8.x-1.x authored by tjwelde
    Issue #2848068 by tjwelde, Jaypan, floown, Jon Pugh: "amp-skip-link"...
KarenS’s picture

Committed. Thanks all!

KarenS’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

floown’s picture

Version: 8.x-1.x-dev » 8.x-3.x-dev

The problem still exist in: amptheme 3.x-dev 9fa3af0

Shawn Conn’s picture

FileSize
391 bytes

As @floown mentions, the 3.x branch does have a similar (but different issue). Changing the template location fromnavigation/amp-skip-link to amp-skip-link fixes the issue.

Vinay15’s picture

Since this issue is Closed (fixed), submitting a patch here would go unnoticed. Created a new issue Template "themes/contrib/amptheme/amptheme/templates/navigation/amp-skip-link.html.twig" is not defined. and submitted a patch there.