-
Notifications
You must be signed in to change notification settings - Fork 1.3k
bs4_book: add OG/twitter metadata #1034
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
Conversation
|
|
|
not that helpful though |
|
I am hoping is finding a way to add the current Rmd as a comment / special div, and then use that when tweaking to go read YAML in the original Rmd file... |
|
each H1 would need some sort of Rmd info attached to them as data attribute 🤔 |
|
Compromise I'll implement next week (after discussion with @cderv) if ok with you @apreshill
So the idea would be to have no customization via YAML as it seemed complex. 🤔 |
|
Hi- this sounds very good to me, and I agree with not adding any per-chapter YAMLs since that it so ingrained into bookdown. I like the Description idea- reminds me of Hugo's auto summary variable (https://gohugo.io/content-management/summaries/#automatic-summary-splitting). |
guess where I got the idea from 😜 |
|
Noting that |
|
Overall, I think we need to understand better how opengraph is really generated to be sure to set the correct value. Some comment on the above.
👍
I think it will be set to the url of the page by default in most case. Some OG simulator for twitter and facebook do for example. but it seems mandatory (better practice) in the resource I read. This could be possible to set / modify when splitting happen in bookdown.
It may be important that description can be set globally too. Like in With @maelle we also discussed the possibility of setting information for each html file in some way, but it is hard with the current design which merge then split, and not header in YAML file except |
|
Maybe another parameter is needed (but in which file 🙃 ) to choose whether the general description should apply to all pages or just the index.html 🤔 |
@cderv do you disagree with this? At the moment my PR doesn't let one use the same description for all pages. |
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.
I think tweaking the og:url is great - bs4_book() allows this easily. We may need to it as the split stage though to tweak also gitbook() format.
For description, I am still wondering what to do. It feels weird to have a description per page that is just a few word of the page content. Is this something usual ? I guess it is done this way for web auto-generated content. Will it be clearer description than a single manual description for the whole book ? It could if it is clearly documented that the 197 first words will be used.
@apreshill what is your thoughts on that ?
BTW bs4_book() does not have description meta (for Google SEO: https://developers.google.com/search/docs/advanced/appearance/good-titles-snippets#meta-descriptions) :
bookdown/inst/templates/gitbook.html
Lines 8 to 9 in adfd645
| <meta name="description" content="$if(description)$$description$$else$$title$$endif$" /> | |
| <meta name="generator" content="bookdown #bookdown:version# and GitBook 2.6.7" /> |
Maybe this should be added ? Related to #1080 probably
It seems highly optional though: https://github.com/joshbuchea/HEAD#meta
BTW this resource about <head> is great !
I have thought about the description per page feature. bookdown is not designed to have YAML field per page so I don't want to introduce that right now. Also we know we can easily add content to header from within a R chunk. metathis works this way but it needs to be 1 Rmd = 1 HTML without merging. Currently a meta set in a Rmd will be put inside all HTML files (as pandoc convert 1 md to 1 HTML before bookdown splits it).
So I don't have a great solution in mind for now about how a user could set a specific description per page.
@apreshill No, I had missed it! Thanks for catching this! Now I am wondering whether the Twitter and OG descriptions should have different lengths, maybe simpler to keep them the same for now? |
cderv
left a comment
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.
The logic is now quite clear
og:description,twitter:descriptionand generaldescriptionwill be the same on each pages- If
descriptionYAML field is set, it will be used forindex.html. If not, a simple default one will be added, with a message to user to add one. - For other pages, the content will be auto generated and replaced.
For other meta,
og:urlwill be adapted on each pagegeneratormeta will be set to indicate bookdown- Other social meta will be set the same for the all pages
There are small fix left. And this is good to go !
cc @apreshill if you want to check this again.
Co-authored-by: Christophe Dervieux <[email protected]>
Co-authored-by: Christophe Dervieux <[email protected]>
Co-authored-by: Christophe Dervieux <[email protected]>
Co-authored-by: Christophe Dervieux <[email protected]>
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.
Thanks for the changes. I think we are good now. We have found all the potential fix.
I just need to test on an example deployment, to see how it looks like on a social card simulator.
@apreshill is this good for you ? See previous comment for the current behavior #1034 (review)
Waiting for you final review before last comestic tweaks and merging.
|
Will do this afternoon. In the meantime, here was my testing repo in case it is helpful: https://github.com/apreshill/bs4booktesting |
|
Tested with https://github.com/cderv/bs4booktesting, a fork of yours as I don't have access. Published here: https://cderv.github.io/bs4booktesting/ This looks good now I believe I also checked that Zotero connector is working now (fix #1080) We are all set and ready to merge. ok for you @apreshill ? |
apreshill
left a comment
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.
This works excellent for me 🎉
Fix #1080
same lines as in gitbook