nbviewer icon indicating copy to clipboard operation
nbviewer copied to clipboard

NBViewer missing page title / meta description

Open dimo414 opened this issue 11 years ago • 9 comments

I noticed while trying to share Peter Norvig's Notebook on XKCD 1313 that NBViewer doesn't provide useful title/description for Facebook shares, and more generally doesn't specify a page title or meta description:

<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

This leads to a poor user experience, as search engines will have a harder time identifying valuable keywords, and sharing services like Facebook will use poor default values:

facebooksharebug

dimo414 avatar Jan 10 '14 18:01 dimo414

Yes, it is planned with twitter-card, google+card...etc, it's just mean some work to allow to tag notebook in metadata, and/or autoextract data.

Carreau avatar Jan 10 '14 18:01 Carreau

Does this fix address the <title> tag being blank as well? I didn't see anything in the diff to that effect.

dimo414 avatar Jan 15 '14 03:01 dimo414

The commits from #167 simply add the ability to set the tags and title within the template. We would still need to pass these on during render, which also means they have to come from somewhere (notebook metadata?).

At least for gists, the title can come from the filename and the description could come from the description field. For vanilla repos, filename could work for title.

For other notebooks/blanks, @Carreau and I chatted about taking the first n characters out of the first cell(s) for description if a description wasn't seen through metadata (or gist description).

rgbkrk avatar Jan 15 '14 04:01 rgbkrk

What about something a little more formatted, like "{filename} Notebook by {username}"?

Additionally, at least in the XKCD notebook there's an <h1> tag that would make a perfect title. Seems reasonable to pull the top-level header element if one exists.

dimo414 avatar Jan 15 '14 15:01 dimo414

Agreed with dimo414. I haven’t contributed to IPython yet but would love to implement this idea if a core dev gives a +1.

merwok avatar Jan 16 '14 10:01 merwok

@dimo414:

What about something a little more formatted, like "{filename} Notebook by {username}"?

For a title default, that sounds good. As long as people can override title within the notebook metadata.

If we had an agreed upon metadata field for username (I'd prefer author), this is perfect. The case ordering would probably be

  • Notebook metadata field for author
  • If on GitHub and not an anonymous gist, the GitHub username
  • Leaving the author out of the formatted title

Additionally, at least in the XKCD notebook there's an <h1> tag that would make a perfect title. Seems reasonable to pull the top-level header element if one exists.

Not everyone uses the top level header, but this sounds good to me as long as we have a sane fallback.

@merwok:

Agreed with dimo414. I haven’t contributed to IPython yet but would love to implement this idea if a core dev gives a +1.

Pull request welcome. Doesn't hurt to try as we'll review it and work with you on it. We'd be happy to get contributions. You'll need to update the renderer too.

rgbkrk avatar Jan 16 '14 14:01 rgbkrk

Note that if you extract title/authors from metadata, we will not guaranty it to work indefinitely unless there is an accepted and implemented IPEP that describe how to store author(s) information in metadata. Keep in mind that those metadata should also be usefull to publish science papers, so IMHO, authors field in metadata should be at least list of dict. And each dict could be smth like a json vcard.

Carreau avatar Jan 16 '14 15:01 Carreau

title (https://github.com/jupyter/nbformat/blob/master/nbformat/v4/nbformat.v4.schema.json#L63) and authors (https://github.com/jupyter/nbformat/blob/master/nbformat/v4/nbformat.v4.schema.json#L67) are now part of the notebook v4 schema.

parente avatar Jul 09 '18 02:07 parente

  • [ ] Extract notebook_title
  • [ ] Pass notebook_title to the notebook.html template (in base.py render_template call)
  • [ ] Add notebook_title to <title> tag in layout.html
  • [x] Add notebook_title Twitter Card metadata (#167)
  • [ ] Add notebook_title OpenGraph RDFa metadata
  • [ ] Add notebook_title Schema.org RDFa metadata
    • @type/typeof: https://schema.org/CreativeWork > https://schema.org/DigitalDocument
    • https://github.com/jupyter/nbformat/pull/46#issuecomment-246002402
      • nbformat:title -> schema:name (http://schema.org/name)

.

  • https://github.com/jupyter/nbviewer/blob/master/nbviewer/templates/layout.html#L40
  • https://github.com/jupyter/nbviewer/blob/master/nbviewer/templates/notebook.html
  • https://github.com/jupyter/nbviewer/blob/master/nbviewer/providers/base.py#L692
  • https://github.com/CodeForAntarctica/codeforantarctica.github.io/pull/3 (schema docs links)
  • https://github.com/CodeForAntarctica/codeforantarctica.github.io/pull/3/files (Twitter Card, OpenGraph RDFa, Schema.org RDFa metadata example)

westurner avatar Jan 24 '19 08:01 westurner