I have Sprout SEO working just great on Channels. However when I go to my channels that are single entries how do I handle custom SEO on a per page basis?

With my channels I can use this code in my templates and it works great:

{% do craft.sproutSeo.meta({ 
id: entry.id,
default: 'default'}) %}

However when on singles the entry.id throws an error.

Variable "entry" does not exist

Do i need to create my own default for each section listed out under Singles?

EDIT AFTER MORE TESTING This seems to be effecting just one or two of my singles. I wrote a little more about my issue but as I was typing so was Ben with the answer :)

Thanks for the help in advanced,



The error "Variable "entry" does not exist means that your current page does not have a variable called entry available. This probably means the problem lies in how you have your Sections or routing set up.

If you remove Sprout SEO from this page and just try to access entry.title in your template, you will probably receive the same error. So, it will be best to troubleshoot that and confirm you have the entry variable available to the page before troubleshooting what might be going on in Sprout SEO.

Once you know the Single is setup correctly and able to display data from the entry variable, the next question would become why is the entry variable not available to the particular part of your page where you are trying to hand off information to Sprout SEO. To answer that, it would be helpful if you posted more information on what your template looks like, where outputting the entry variable to the page directly works, and where trying to pass the entry.id variable on the page throws an error.


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.