I am trying to create a meta include to display all my meta data and I have the following set up so far:
3. {% if craft.request.getSegment(1) != "404" and craft.request.getSegment(1) != "databytes" %}
4. <title>{% if entry.metaTitle is defined %}{{ entry.metaTitle }}{% else %}{{ entry.title }}{% endif %} | {{ siteName }}</title>
5. {% if entry.metaDescription is defined %}
6. <meta name="description" content="{{ entry.metaDescription }}">
7. {% endif %}
8. {% endif %}
{# 404 =============== #}
{% if craft.request.getSegment(1) == "404" %}
<title>Page Missing | {{ siteName }}</title>
<meta name="description" content="Sorry the page you are looking for is missing, it may have been moved or deleted, please use the navigation to search for similar content.">
{% endif %}
If I visit main pages the code works and if I go to example.com/404 the code works, but if I visit an invalid url example.com/foo then I get a Twig Error Runtime error: