0

I've got a single set up to point to /calendar on my site. the single has only one field, SEOmatic so I can add meta title, description etc.. the rest of he page is loaded with content from the photoblog channel.

The issue is that I've got things organized by months and if there are no month segments in the url I redirect to the current year and month so that for example today the site would redirect to /calendar/2016/08 and when it does this the meta tags are getting pulled from the homepage single and I don't know why.

I also have a template route set like this enter image description here

If I remove the redirect code for the year/month the meta tags come through correctly, but if it's there no luck.

How can I fix this.

simplified template code here:

{% if craft.request.segment(2) == "" %}
  {% redirect "/calendar/" ~ now.year ~ "/" ~ now|date("m") %}
{% endif %}


{#
  // take month digit and convert to date format so we can output
  // the full month name below next to the year
  // if this isn't done will only output 08 or 09 for august or september etc...
#}
{% set viewMonth = '00-' ~ month ~ '-01' %}

{% set entryAfterDate = year ~ '-' ~ month %}
{% set entryBeforeDate = year ~ '-' ~ (month + 1) %}

          {% set entries = craft.entries.section('photoblog').limit(null).after(entryAfterDate).before(entryBeforeDate) %}

          {% for entry in entries | reverse %}

            more code here

          {% endfor %}

{% endblock %}
  • Does that route work if you remove the .html? – Lindsey D Sep 1 '16 at 19:15
2

If I understand your question correctly you might be better off using SEOmatic's Template Meta feature.

Using the Template Meta you're be able to set the meta info on a per template basis. So in this case you'd create a one to use for your calendar.html template.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.