Skip to content

Generate links to index.html #4258

Open

Description

@lrhn

The generated link to a library has the form <a href="ascii/">ascii</a>.

That makes it hard to examine the generated docs locally, because the browser will open the local .../ascii/ directory, not the .../ascii/index.html file that a web server would (presumably) redirect to or send instead when you ask for the URI .../ascii/.

If the link had been <a href="ascii/index.html">ascii</a>, you could browser generated docs directly from disk.

The current behavior is deliberate. From lib/src/model/library.dart:

    // The file name for a library is 'index.html', so we just link to the
    // directory name. This keeps the URL looking short, _without_ the
    // 'index.html' in the URL.
    return '${package.baseHref}$dirName/';

That works when generating HTML for a web server. If the URL being short in that case is more important than making it easily locally readable, then the current behavior is what we want.

(Unless we can have a flag to choose? As a package author, I want to check how my docs look before publishing. That's less convenient with the current behavior. Or we could have a dart doc server command which generates the docs, then serves them as a HTTP server on a local port.)

Activity

  1. hiSandog commented on Jul 11, 2026

    @hiSandog

    A generation option is preferable to changing hosted canonical URLs globally: keep clean directory links for web output, but allow file-browsable links that include index.html. The option must apply consistently to libraries, classes, search results, breadcrumbs, and relative links at different nesting depths. An alternative dart doc --serve command is useful for preview, but it does not help archives or offline documentation bundles opened directly from disk.

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

    type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions