Skip to content

Resolve assets referenced in head, header, and footer #692

Closed
@mbostock

Description

@mbostock

A common use case is to put a favicon in the head config option:

<link rel="apple-touch-icon" href="/favicon.png">
<link rel="icon" type="image/png" href="/favicon.png" sizes="512x512">

There are two problems with this approach:

  1. The favicon.png isn’t detected as a referenced file, so unless some other code references this, it won’t be included in the built site.
  2. The /favicon.png link will work locally, but it won’t get rewritten to a relative link on build, and so will result in a broken link if the built site isn’t served at the root of a domain.

We’ve talked about having a “public” assets folder #169 but that only addresses problem (1), not problem (2). If we resolved reference assets in the head, header, and footer, then we’d solve both problems at once: we’d include the referenced files in the built output, and we’d rewrite the links to be relative. We already do this for the scripts option, so it seems reasonable to extend it to these other HTML fragments. (Though it’s extra tricky because these options can be overridden by the page.)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions