jekyll / jekyll-seo-tag

A Jekyll plugin to add metadata tags for search engines and social networks to better index and display your site's content.
https://jekyll.github.io/jekyll-seo-tag
MIT License
1.65k stars 289 forks source link

How to define JSON-LD for Events? #158

Closed azizur closed 7 years ago

azizur commented 7 years ago

How to define JSON-LD for Events?

At the moment I am able to send seo.type as Event and I have layout file markup with appropriate attributes for events.

My manual HTML version renders correctly as Event. However, the JSON-LD version generated by jekyll-seo-taghas 5 errors according to Google Structured Data Testing Tool.

If you want to see the source repo.

pathawks commented 7 years ago

We need to be clearer about what we do and do not support. Because this data was constructed with blog posts or news articles in mind, it does not work well with any arbitrary type, such as event.

I think for sites that need more granular control over the metadata, there is little advantage in using a plugin like this.

Perhaps our documentation should include examples of the types we expect.

azizur commented 7 years ago

@pathawks thanks for your prompt comment.

I am wondering if it's possible to have a flag to disable JSON-LD for arbitrary types?

azizur commented 7 years ago

Looking at https://github.com/jekyll/jekyll-seo-tag/blob/master/lib/template.html#L193-L237 it does not seem possible to this at the moment.

jekyllbot commented 7 years ago

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.

azizur commented 7 years ago

This is still an issue. It would be really useful to have an option to turn off JSON-LD for unsupported arbitrary types. That way who wants can implement their own arbitrary types.

aav7fl commented 7 years ago

@azizur While this doesn't change the plugin handling, you could always use some liquid hackery to remove the JSON-LD tags if you can guarantee they match a text pattern like the meta tags.

For example, I need to clear out certain meta tags and rewrite them my own way due to conflicts with amp-Jekyll.

{% capture seo_text %}{% seo %}{% endcapture %}
<!-- Extract extra <title> tag. -->
{% assign open_tag = "<title>" %}
{% assign close_tag = "</title>" %}
<!-- Remove <title> tag and contents from `seo_text` -->
{% assign extract = seo_text | split: open_tag | last | split: close_tag | first | prepend: open_tag | append: close_tag %}
{% assign seo_text = seo_text | remove: extract %}

This isn't a great solution. For this example, it is only parsing for strings which can be broken if you decide to include </title> in your title for whatever reason. With the JSON-LD, it would be even more difficult to guarantee a string match. But maybe this can help you if it's a very small/specific use case.

azizur commented 7 years ago

@aav7fl It's not the best solution as you already have mentioned.

I would rather jekyll-seo-tag not output JSON-LD for unsupported arbitrary types.

If I am going to have to patch output from one plugin to make it fit it defeats the purpose of a plugin. At this point just copy the plugins and modify it and release it as plugin with the just the fix you need.

azizur commented 7 years ago

@benbalter could do with some direction on this issue. Would you or rest of the team entertain PR that will either add options to turn-off or implement support for unsupported arbitrary types?

benbalter commented 7 years ago

How many different types are there? How much do they differ? What fields need to be added/removed from website or blog post to support events?

azizur commented 7 years ago

@benbalter Just to give you an idea here is a list of a commonly used type:

Each of them will have mandatory fields that will need to be supported, else we'll end up with an invalid JSON-LD object.

I highlighted Event because that's what I am currently focused on. I will later need to focus on Places and Organisations as well.

jekyllbot commented 7 years ago

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.