NBViewer missing page title / meta description
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:

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.
Does this fix address the <title> tag being blank as well? I didn't see anything in the diff to that effect.
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).
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.
Agreed with dimo414. I haven’t contributed to IPython yet but would love to implement this idea if a core dev gives a +1.
@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.
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.
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.
- [ ] Extract
notebook_title - [ ] Pass
notebook_titleto the notebook.html template (in base.pyrender_templatecall) - [ ] Add
notebook_titleto<title>tag in layout.html - [x] Add
notebook_titleTwitter Card metadata (#167) - [ ] Add
notebook_titleOpenGraph RDFa metadata - [ ] Add
notebook_titleSchema.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)