I have a blog setup with a Categories, Archive and Tags.
In my _layout template I've been using the following to pull in SEO titles from fields, or Page/Category Titles is that's not been defined.
{% if entry is defined %}
{% set seoTitle = entry.seoTitle %}
{% set seoDescription = entry.seoDescription %}
{% set seoImage = entry.seoImage %}
{% set seoType = entry.seoType %}
{% set title = entry.title %}
{% set url = entry.url %}
{% endif %}
{% if category is defined %}
{% set seoTitle = category.title %}
{% set seoDescription = category.title %}
{% set seoImage = category.seoImage %}
{% set seoType = category.seoType %}
{% set title = category.title %}
{% set url = category.url %}
{% endif %}
<title>{{ siteName }} - {% if seoTitle is not empty %}{{ seoTitle }}{% else %}{{ title }}{% endif %}</title>
<meta name="description" content="{% if seoDescription is defined %}{{ seoDescription }}{% else %}{{ title }}{% endif %}"/>
{% if url is defined %}<link rel="home" href="{{ url }}" />{% endif %}
<meta name="twitter:card" content="summary" />
{% if url is defined %}<meta property="og:url" content="{{ url }}" />{% endif %}
<meta property="og:title" content="{% if seoTitle is not empty %}{{ seoTitle }}{% else %}{{ title }}{% endif %}" />
<meta property="og:description" content="{% if seoDescription is defined %}{{ seoDescription }}{% else %}{{ title }}{% endif %}" />
{% if seoImage is defined %}
{% for image in seoImage %}
<meta property="og:image" content="{{ image.getUrl()}}" />
{% endfor %}
{% endif %}
How should I approach this for the archive and tag pages as simply doing something like the below doesn't work?
{% if tag is defined %}
{% set seoTitle = tag.title %}
....
{% endif %}
{% if craft.request.getSegment(x) == tag.slug %}