Skip to content

rustdoc: improve web search snippets #82283

Description

@jsha

Boilerplate

Some (but not all) search result snippets for rust items include the boilerplate "1.0.0[−][src]". Example screenshots below are linked to the Google search results page they are taken from.

Search results for "rust slice" show the boilerplate:
image

Search results for "rust slice" omit the boilerplate:
image

Per https://developers.google.com/search/docs/advanced/appearance/good-titles-snippets and https://developers.google.com/search/docs/advanced/crawling/special-tags#data-nosnippet, we can wrap this particular piece of boilerplate in <span data-nosnippet> to omit it from snippets.

Low-information meta descriptions

Also, search engines commonly make snippets from the <meta name="description" value="..."> tag. The tag rustdoc currently generates is very low-information. For instance:

API documentation for the Rust slice mod in crate std

API documentation for the Rust Error trait in crate std.

It would be much better to fill this tag with the first sentence (or two) of actual documentation. For instance:

A dynamically-sized view into a contiguous sequence, [T]. Slices are a view into a block of memory represented as a pointer and a length.

Error is a trait representing the basic expectations for error values, i.e., values of type E in Result<T, E>.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-rustdoc-uiArea: Rustdoc UI (generated HTML)C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions