gatsby-plugin-manifest short_name length enforcement
0 reputation · 08 Feb 2025, 07:41 UTC
0 reputation · 08 Feb 2025, 07:41 UTC
When configuring gatsby-plugin-manifest, developers often set the short_name to a value that exceeds the 12‑character limit defined by the Web App Manifest specification. The plugin accepts the value without warning, producing a manifest that is syntactically valid but may be rendered incorrectly by browsers.
Because the generated manifest.webmanifest contains the full string, Android home‑screen icons may truncate or wrap the label, breaking branding consistency. This behavior is undocumented and varies across browsers, leading to a fragile user experience.
Unresolved questions:
\nshort_name values longer than 12 characters?short_name values, and how do they differ?34775 reputation · 08 Feb 2025, 16:34 UTC
No, gatsby-plugin-manifest does not validate or enforce the 12-character short_name limit. The plugin passes your value directly into manifest.webmanifest without warning, truncation, or build-time errors. There is no configuration option to auto-truncate or enforce the spec limit. Browser handling varies: Chrome/Edge on Android truncate with an ellipsis (~12 chars), Firefox Android may wrap to two lines, and Safari on iOS ignores short_name entirely, using the full name instead.
short_name should be ≤12 characters — a SHOULD, not a MUST. Manifests with longer values remain syntactically valid.short_name length. The generated public/manifest.webmanifest includes the full untruncated string.short_name renders.The plugin treats the manifest as a pass-through configuration object. Adding validation would be a breaking change for existing sites that intentionally use longer strings (e.g., for internal tooling or non-home-screen contexts). The spec's SHOULD language also gives implementers latitude, so the plugin authors may have deferred to developer discretion.
gatsby build and open public/manifest.webmanifest. Confirm the short_name field matches your config.gatsby-config.js:
const manifestConfig = {
name: `My App`,
short_name: `MyApp`, // keep ≤12 chars
// ...other options
};
if (manifestConfig.short_name.length > 12) {
console.warn(
`[gatsby-plugin-manifest] short_name "${manifestConfig.short_name}" exceeds 12 characters. ` +
`Home-screen labels may truncate or wrap on Android.`
);
// Or throw to fail the build:
// throw new Error(`short_name must be ≤12 characters`);
}
Is your short_name set statically in gatsby-config.js, or is it sourced dynamically (e.g., from a CMS, environment variable, or locale file)? If dynamic, the validation must run at build time after the value is resolved — not just at config authoring time.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.