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

Truncate description field in injected JSON-LD to 5000 characters #1899

Open
amoeba opened this issue Oct 11, 2021 · 2 comments · May be fixed by #2559
Open

Truncate description field in injected JSON-LD to 5000 characters #1899

amoeba opened this issue Oct 11, 2021 · 2 comments · May be fixed by #2559
Assignees
Labels
bug jsonld Adding JSON-LD to MetacatUI pages
Milestone

Comments

@amoeba
Copy link
Contributor

amoeba commented Oct 11, 2021

@mbjones noted a few of our datasets on arcticdata.io were failing Google's schema:Dataset validation due to "Invalid string length in field "description". When we go into the Search Console, we can see that Google is seeing the description field. We then noticed that Google specifies that the description field should be between 50 and 5000 characters:

The summary must be between 50 and 5000 characters long.

From: https://developers.google.com/search/docs/advanced/structured-data/dataset#dataset

In at least one of the offending documents, the abstract is 5779 characters so the above rule seems like a likely cause for the failed validation. Let's truncate the description field to 5000 characters for all records and hopefully these errors will go away.

@amoeba
Copy link
Contributor Author

amoeba commented Oct 13, 2021

As mentioned in DataONEorg/dataone#12 (comment), we should also pad descriptions that are too short. Something like "For complete metadata, visit..." would do the trick.

@robyngit robyngit self-assigned this Oct 7, 2024
@robyngit robyngit added this to the 2.32.0 milestone Oct 7, 2024
@robyngit robyngit added bug jsonld Adding JSON-LD to MetacatUI pages and removed enhancement labels Oct 21, 2024
@robyngit
Copy link
Member

Right now, the logic for managing JSON-LD is spread across multiple views:

  • CatalogSearchView: injects JSON-LD for the data catalog
    • removes jsonld during the onClose method. Identifies with the id jsonld.
  • AppView: In the render function, injects JSON-LD for the application itself based on a template.
  • DataCatalogView (deprecated?): The method getLinkedData generates JSON-LD for the catalog but doesn’t seem to be actively used.
  • MetadataView: The insertJSONLD method injects JSON-LD for datasets or metadata records. generateJSONLD generates it.
  • router.js: removes jsonld (identifies with the id jsonld) when initializing.

If we want to add the general functionality to truncate or pad descriptions, we would need to add this logic in multiples places. So the first step is to consolidate the JSON-LD logic into a single model and view. Then we can add the functionality to truncate or pad descriptions in a single place.

robyngit added a commit that referenced this issue Oct 23, 2024
- Model can handle Dataset and DataCatalog types, and can import attributes from a template string.
- Model includes methods for truncating or padding descriptions to meet Google's requirements.
- Add unit tests for the model.

Issue #1899
robyngit added a commit that referenced this issue Oct 23, 2024
- Remove logic for creating and inserting schema.org JSON-LD from AppView, DataCatalogView, MetadataView, and CatalogSearchView.
- Use the SchemaOrg model that is set on the MetacatUI.AppView instead.
- Move the jsonLD template importing to the SchemaOrgView.
- Use the jsonLD template content in jsonLD tag as default for non-dataset and non-dataCatalog pages.

Issue #1899
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug jsonld Adding JSON-LD to MetacatUI pages
Projects
None yet
2 participants