# Noindex auf 404-Seiten

**URL:** <https://forum.shopware.com/t/noindex-auf-404-seiten/97131>\
**Category:** Programmierung\
**Created:** [16. November 2022 um 14:00 UTC](https://forum.shopware.com/t/noindex-auf-404-seiten/97131 "2022-11-16T14:00:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ansgar](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/ansgar/32/7871_2.png) [@ansgar](https://forum.shopware.com/u/ansgar)\
**Post date:** [16. November 2022 um 14:00 UTC](https://forum.shopware.com/t/noindex-auf-404-seiten/97131/1 "2022-11-16T14:00:28Z")

</div>

Hallo,

ich hätte gern auf der 404-Seite ein geändertes robots Tag. Statt „index,follow“ will ich „noindex,follow“ ausgeben. Meine Subscriber-Lösung auf `KernelEvents::EXCEPTION` macht aber rein gar nichts:

```auto
public static function getSubscribedEvents() {
	return [
		KernelEvents::EXCEPTION => 'onKernelException',
	];
}

public function onKernelException(ExceptionEvent $event): void
{
    $e = FlattenException::createFromThrowable($event->getThrowable());
	if($e->getClass() == 'NotFoundHttpException') {
		$salesChannelContext = $this->salesChannelContextFactory->create('', $this->salesChannel->getId(), [SalesChannelContextService::LANGUAGE_ID => $this->salesChannel->getLanguageId()]);
		$page = $this->genericPageLoader->load($event->getRequest(), $salesChannelContext);
		$page->getMetaInformation()->setRobots('noindex,follow');
	}
}

```

Kann es sein dass mein `$page` gar nicht auf die aktuelle Seite zugreift?

---

<div class="post-metadata">

**Author:** ![ansgar](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/ansgar/32/7871_2.png) [@ansgar](https://forum.shopware.com/u/ansgar)\
**Post date:** [16. November 2022 um 16:40 UTC](https://forum.shopware.com/t/noindex-auf-404-seiten/97131/2 "2022-11-16T16:40:13Z")

</div>

Scheinbar wird bei 404-Seiten im Twig ein leeres `activeRoute` gesetzt. Entsprechend habe ich mal in meiner `custom/plugins/MeinPlugin/src/Resources/views/storefront/layout/meta.html.twig` sowas gemacht:

```auto
{% block layout_head_meta_tags_robots %}{% apply spaceless %}
    {% if activeRoute is null %}
        noindex,follow
    {% else %}
        {{ parent() }}
    {% endif %}
{% endapply %}{% endblock %}

```
