Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature for adding noindex, nofollow meta tags in non-production (OSOE-621) #56

Closed
Piedone opened this issue May 6, 2023 · 4 comments · Fixed by #60
Closed

Feature for adding noindex, nofollow meta tags in non-production (OSOE-621) #56

Piedone opened this issue May 6, 2023 · 4 comments · Fixed by #60
Assignees
Labels
enhancement New feature or request

Comments

@Piedone
Copy link
Member

Piedone commented May 6, 2023

Staging and other non-production environments can be open to the public internet. To prevent search bots from indexing these (and thus duplicating production content), let's add a new module that when enabled, adds a noindex, nofollow meta tag when the app is not running in a production environment.

<meta name="robots" content="noindex, nofollow">

The environment can be checked with IHostEnvironment.IsProduction(). However, add a separate configuration coming from a configuration provider that indicates if the current environment is production or non-production, in case ASP.NET Core should be told it runs in Production but not actually (like in staging, that should be as close to production as possible).

Jira issue

@Piedone Piedone added the enhancement New feature or request label May 6, 2023
@github-actions github-actions bot changed the title Feature for adding noindex, nofollow meta tags in non-production Feature for adding noindex, nofollow meta tags in non-production (OSOE-621) May 6, 2023
@DemeSzabolcs
Copy link
Member

Any good name suggestions? SearchBotBlocker, NoIndexNoFollow, EnvironmentMetaTag. I think SearchBotBlocker is fairly accurate.

@DemeSzabolcs DemeSzabolcs self-assigned this May 18, 2023
@DemeSzabolcs
Copy link
Member

DemeSzabolcs commented May 18, 2023

Must we use the meta tag? I mean this is easily solvable with a middleware, that adds a response header:

context.Response.Headers.Add("X-Robots-Tag", "noindex, nofollow");

The difference is, that this way there will be no

<meta name="robots" content="noindex, nofollow">

tag in the HTML file.

According to my research, there are no meaningful differences. The only difference is: "A robots header can also override a meta tag if they have conflicting values."

Actually I think it's better, since we can only use the meta tag for HTML files.

@Piedone
Copy link
Member Author

Piedone commented May 18, 2023

For the name, EnvironmentRobots?

I didn't know about the header, but I'd use both to be sure (adding the meta tag is just simply an IResourceManager call from a filter).

@DemeSzabolcs
Copy link
Member

Okay, I agree. After some more research I discovered, that using both method is the best, since there are some cases where one is not supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants