bookdown icon indicating copy to clipboard operation
bookdown copied to clipboard

Description tag for every page or other SEO best practices?

Open Scinawa opened this issue 3 years ago • 5 comments

Dear community,

I discovered that the YAML tag "description" should only be used once. Indeed, if I try to put it in every .Rmd page of my book, the engine takes only the last entry of the book, overwriting all the previous entries.

Is there a way to use description tags, (or anything that can help SEO) for single pages of a bookdown project?

Thank you!

Scinawa avatar Feb 13 '22 06:02 Scinawa

Hi,

The different formats have some limitation regarding this meta information, part of it because YAML header are only intended to be used in index.yml and not each file. So initially, there is only one description possible. gitbook() format only allow one description for the whole content unfortunately, so same one for every page. With bs4_book(), there was an improvement made (https://github.com/rstudio/bookdown/pull/1034) and each page should have a description based on the content. It is auto-generated though and can't be configured.

Unfortunately, there is not easy way for bookdown to allow user to configure a meta tag per file. Logical way would be to have a YAML header per file, but that is not how bookdown project works, and that would be a big rewrite (not plan for now).

Current workaround would be for a project author to write its own wrapper workflow to post process the files in order to set its desired description per file.

We know bookdown output is not the best for SEO. Hopefully, we'll be able to find solution to improve that in the future.

cderv avatar Feb 14 '22 09:02 cderv

In terms of implementation, one possible way is:

  1. Users insert a different HTML comment on each page of the form, say, <!--#description Here is a summary of the current page. -->.
  2. We (bookdown) find the comment, and add it to the <meta> tag of that .html file.

yihui avatar Feb 14 '22 14:02 yihui

Thank you so much! Your software is so beautiful :)

Scinawa avatar Feb 14 '22 16:02 Scinawa

I was wandering.. what about opening some form of bounty for the most laborious features? Bounties that you can receive from the community (or you can pay to someone that contributes)!

Scinawa avatar Feb 17 '22 03:02 Scinawa

This is similar to the problem of the the meta property "og:url" being set improperly to the same URL for every page in the book, as seen in issue #970.

Though the solution to that one is remarkably easy: just don't set the og:url and it will be set to the current page's url, which is what it should be. I even provided a patch, but it's never been accepted. Not sure if there's something wrong with it or if it just fell off the radar.

jtbayly avatar Mar 14 '22 17:03 jtbayly