-
Notifications
You must be signed in to change notification settings - Fork 294
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
This way to a passing Rich Results logo test #429
base: master
Are you sure you want to change the base?
Conversation
If I read this correctly, this seems to be solving a different problem than #428, although there seems to be some overlap and both PRs modify the @benjithaimmortal could you have a quick look at #428 and confirm whether these are two distinct problems? Also, I've tried to do some quick googling on the |
@DarkWiiPlayer you're right! We're approaching the same point in the code but doing very different things. I think my results should precede yours [in the code logic, that is], so you can modify things after the correct formatting to the JSON-LD has been applied.
|
@benjithaimmortal Yes, absolutely. However, I'm wondering how that would work with the way my PR currently works where you build a new tree of json data that gets merged into the autogenerated one because now that includes an array, so one has to throw in a numeric index. For example, if you have a I could add a bunch more logic to filter subtrees by their |
@DarkWiiPlayer yeppers. I encountered the same when I was building mine. IMO the need is a simple hash from the yaml settings, and it's overcomplicated by the Ruby magic inside of a new Jekyll instance. Perhaps it could be extracted entirely? I'd love to see something that simply builds the JSON out of |
If you're worried about the array itself, perhaps we could make a hash with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing values of json_data[@graph]
with index numbers (since the object is an Array) seems less intuitive to me as against accessing the values with explicit keys.
Nevertheless, this proposal needs some changes.
# assign publisher and remove it from the array | ||
# (because I don't know the meta-programming involved in instantiating it) | ||
publisher = graph["publisher"] || nil | ||
graph.delete("publisher") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could merge these two lines into one:
publisher = graph.delete("publisher")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ashmaroli I think I don't know enough about Ruby for this one. Sorry!
publisher
should be set to the inner hash graph['publisher']
, and not the full graph
hash. Does the refactor do that?
Excellent! I'll get to it and modify this ASAP. Thank you all for your comments and help. |
Yep, let's remove these comments! Co-authored-by: Ashwin Maroli <[email protected]>
Yep, let's remove these comments! Co-authored-by: Ashwin Maroli <[email protected]>
Yep, let's remove these comments! Co-authored-by: Ashwin Maroli <[email protected]>
A forward
@ashmaroli Thank you for your patience as I got enough Ruby under my belt to even get this far. I started using
pry
to debug the code in-stream, and it allowed me to even test the output as it was rendered inrspec
. This is now passing the test on Google, and passingrspec
andrubocop
. I don't think my code is great, but it was an attempt. My first! Let's change any/all of it in the hopes that the overall contribution helps this cool open source project.--Benji
TL;DR
"@type" => "Organization"
"@type" => "Organization"
to always be separate from"@type" => "WebPage"
"publisher"
We're trying to get a set
logo
to pass a Rich Results test, and there are a few problems.Google may have changed this, but at the moment it isn't reading things inside of the "publisher" key. As I mentioned in my open issue we need to find a way to modify the hash to remove it from
"publisher"
(which isn't a type property on schema.org anyway).My proposal: let's take a look at Yoast, because they do this a lot
Yoast likes to make tons of different
@type
attributes, and house them as an array of objects inside of@graph
. That's what I'm finding on schema.org, too. So now we want things to look like this:I'd rather manipulate the hash than metaprogram
Results of the change
Original Output:
New Output (confirmed on Rich Results Test, when you change the canonical url to a valid one):