Fix anonymous author microdata for Google Rich Results#1015
Open
rxchun wants to merge 2 commits intoq2a:bugfixfrom
Open
Fix anonymous author microdata for Google Rich Results#1015rxchun wants to merge 2 commits intoq2a:bugfixfrom
rxchun wants to merge 2 commits intoq2a:bugfixfrom
Conversation
## Summary Adds an empty `<meta itemprop="url" content="" />` for anonymous post authors to satisfy Google structured data requirements, without affecting registered users. ## Details - When `$microdata` is true and the post author is anonymous, the generated HTML now wraps the author name in: ``` <span itemprop="author" itemscope itemtype="https://schema.org/Person"> <span itemprop="name">anonymous</span> <meta itemprop="url" content="" /> </span> ``` - This prevents Google Rich Results warnings about missing `url`. - **Registered users** (with `<a>` links) are unaffected. - The patch does **not** change any IP display or other functionality. ### Testing - Verified anonymous posts render the proper `<meta itemprop="url">`. - Verified registered users continue to render their existing linked name correctly. ### Issue addressed Google structured data requires an `author/url` field. Anonymous authors previously triggered warnings in Rich Results testing tools.
The URL needs to contain content, as reported by the webmaster who found this issue. Since there is no default user to reference for anonymous content, or stray content like StackOverflow uses, the best solution here is to set the link to the **Users** page. This ensures that SEO has a valid page to reference without leading to a 404 error. Using `mysite.com/users/anonymous` could be problematic since it might either: - Point to a real user with the username "anonymous," or - Result in a 404 error if such a user doesn’t exist. By pointing to the general **Users** page (`mysite.com/users/`), we avoid these issues and maintain valid structured data without exposing sensitive information or creating misleading URLs.
Author
|
The URL actually needs to contain content, as reported by the webmaster who found this issue. Since there isn't a default fallback user to reference anonymous content, or attribute stray content like StackOverflow does with the user @community, the best solution here is to set the link to the Users page. This ensures that SEO has a valid page to reference without leading to a 404 error. Using
By pointing to the general Users page ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an empty
<meta itemprop="url" content="" />for anonymous post authors to satisfy Google structured data requirements, without affecting registered users.Details
$microdatais true and the post author is anonymous, the generated HTML now wraps the author name in:url.<a>links) are unaffected.Testing
<meta itemprop="url">.Issue addressed
Google structured data requires an
author/urlfield. Anonymous authors previously triggered warnings in Rich Results testing tools.