jekyll/jekyll-seo-tag

Logo Rich Text Results Type in Unsupported Format

benjithaimmortal opened this issue · 6 comments

I think Google has updated their Rich Results Text matching criteria for Logos

I'm testing this on my personal site as an example: it seems that Google's Rich Text Results for a logo are only filling when the LD+JSON is set to @type: Organization, with logo: [img_url] and url: [baseurl]. jekyll-seo-tag is outputting them inside of "Publisher": which is not recognized by the test.

https://search.google.com/test/rich-results?url=https%3A%2F%2Fwww.monjibram.com%2F&user_agent=1

If someone can confirm that I'm implementing this correctly in _config.yml, I think this needs a change:

logo: assets/images/Benji.jpg
type: Organization

I've identified the potential area in the source code: lib/jekyll-seo-tag/json_ld_drop.rb lines 23 and 57.

Add Type "Organization" to valid types

Line 23: VALID_ENTITY_TYPES = %w(BlogPosting CreativeWork).freeze
Change to: VALID_ENTITY_TYPES = %w(BlogPosting CreativeWork Organization).freeze

Update this

publisher Method on Line 57:

      def publisher
        return unless logo

        output = {
          "@type" => "Organization",
          "logo"  => {
            "@type" => "ImageObject",
            "url"   => logo,
          },
        }
        output["name"] = page_drop.author.name if page_drop.author.name
        output
      end

Change to:

      def publisher
        return unless logo && (page_drop.type == 'Organization')
        output["logo"] = logo
        output["name"] = page_drop.author.name if page_drop.author.name
        output
      end

I haven't written Ruby in many moons, so please forgive any errors!

With a bit more research, I came across this as an alt output format for the publisher method:

 output = {"@graph": [{
    "@type" => "Organization",
    "logo": {
      "@type" => "ImageObject",
      "url" => url
    },
    "name": page_drop.author.name,
    "url": page_drop.canonical_url
  }]}

@benjithaimmortal You're free to formalize your suggestions by submitting a pull request with your change and adding / updating tests as necessary.

@ashmaroli I'd love to! I'm a little unsure of how to instantiate the code to test it.. I have successfully run RSPEC but I might be doing that wrong too. If you help me to get started I'll happily keep updating the LD+JSON for any other things I can find.

Setting up the dev environment isn't that difficult nor to grasp the rspec unit tests.
To set up, clone the repository, move into clone directory and run:

bundle install
bundle exec rspec
bundle exec rubocop

The unit test for this change would go into spec/jekyll_seo_tag/json_ld_drop_spec.rb
If you get stuck, commit whatever changes you have made and open a pull request. I'll provide feedback as required.

Awesome, I've been working on it and hope to have something back soon! Thanks for your support, I'll @ you when I push it.

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.