nystudio107 / craft-seomatic

SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.
https://nystudio107.com/plugins/seomatic
Other
162 stars 68 forks source link

Environment not correctly respected for robots and tracking scripts, when manuallySetEnvironment is set to enabled #1430

Closed thijskaspers closed 3 months ago

thijskaspers commented 4 months ago

Describe the bug

Our environment is set to local via an ENV, and the CP dashboard page states the following:

The SEOmatic environment, either live, staging, or local. This setting controls whether certain things render, and is configured in [Plugin Settings](http://localhost/beheer/seomatic/plugin).

Only in the live production environment will Google Analytics and other tracking tags send analytics data.

SEOmatic also automatically sets the robots tag to none for everything but the live production environment.

However, we are still seeing the Google Tagmanager script being inserted, and meta robots tag set to 'all', even though the environment is not live, but local instead.

We have noticed this has to do with the manuallySetEnvironment lightswitch. If we disable that, the environment is still local (being automatically determined by SEOmatic), but now, tracking scripts are not rendered and robots is set to none correctly.

This is unexpected behavior? It should check the environment name, regardless of the manuallySetEnvironment setting?

To reproduce

Steps to reproduce the behaviour:

  1. Enable manually set environment
  2. Set environment name to 'local' or 'staging', either in the CP or via ENV
  3. See template source, robots is set to 'all' instead of 'none', meaning local and staging environments will end up in Google index

Expected behaviour

SEOmatic should check the environment name, regardless of the manuallySetEnvironment setting? local == local.

Versions

khalwat commented 3 months ago

I just attempted to replicate this, but was unable to.

I turned on a tracking script, and then I turned on Manually Set SEOmatic Environment and set Environment to live and the tracking scripts were rendered, and the robots tag was rendering as I'd expect:

<meta name="robots" content="all">

Then keeping Manually Set SEOmatic Environment on, I changed the Environment to local and the tracking scripts were not rendered. Additionally, the robots tag was rendered as I'd expect:

<meta name="robots" content="none">

So I'm guessing something else may be afoot here?

I'm happy to help you diagnose this further, but I think it may be some other complication that is causing this on your end. Or at least I'm unable to reproduce it here.

thijskaspers commented 3 months ago

Thanks Andrew! We are seeing the behavior, so let me further dive into it and do some debugging to find out what is causing this. I'll keep you posted