nielsenramon / chalk

Chalk is a high quality, completely customizable, performant and 100% free Jekyll blog theme.
http://chalk.nielsenramon.com
MIT License
1.23k stars 442 forks source link

Adding Structured Data #129

Open xRahul opened 6 years ago

xRahul commented 6 years ago

Hey guys, I have recently started to dive deep into the SEO aspects of the theme. As I can see, there is no structured data for List of Articles, each article, author etc. Adding some basic structured data can really enhance the website in search results when users are using this theme. We can use schemas like BlogPosting, Article etc on the pages and give them a boost in the search. Reference commit

migueldemoura commented 6 years ago

This is a good idea, it is standardized as far as I know and it makes sense. Is there any way of adding the tags without javascript? I used to do this with html tags in the <head>, not sure if that's still possible.

xRahul commented 6 years ago

No javascript is required to add it. The json-ld format uses the script tag, but that's just semantics. Check out the structured data page by google It is just a properly formatted json wrapped in script tags. It's the default standard nowadays

migueldemoura commented 6 years ago

What I knew before was https://www.w3.org/TR/microdata. Could you place the json in a separate .js file? That way you get better caching and it doesn't interfere with a proper CSP definition.

xRahul commented 6 years ago

microdata is an older format and search engines are moving towards json-ld format now.

Google recommends using JSON-LD for structured data whenever possible.

Also, it's structured data for the page, so moving it to a separate file doesn't make sense. We can add it in the tag just like the og and twitter tags we have. It can also be added in the body. Also, what do you mean by CSP definition? I'm unfamiliar with the term.

migueldemoura commented 6 years ago

Yes yes, I read their recommendation.

We can add it in the tag just like the og and twitter tags we have. How would that look like?

CSP "is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks." The correct way of using it would break the inline scripts (w/o nounces), hence my question about moving it to another file. This should be a non-issue for most users, just asking as myself and a couple others I know will have to find a workaround :)

All in all this a great addition!

xRahul commented 6 years ago

As this is a theme, I did not add too much information in the structured data, but I've made it extensible so that users can add their own.