Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: Favicon sizes conform to Google Search guidelines (#3527)

Ivan Starkov9626c6dee59f
diff --git a/apps/builder/app/builder/features/project-settings/section-general.tsx b/apps/builder/app/builder/features/project-settings/section-general.tsx
index f81b3f64ec..cdef955683 100644
--- a/apps/builder/app/builder/features/project-settings/section-general.tsx
+++ b/apps/builder/app/builder/features/project-settings/section-general.tsx
@@ -29,6 +29,7 @@ import { CodeEditor } from "~/builder/shared/code-editor";
import { $userPlanFeatures } from "~/builder/shared/nano-states";
const imgStyle = css({
+ objectFit: "contain",
width: 72,
height: 72,
borderRadius: theme.borderRadius[4],
@@ -137,7 +138,7 @@ export const SectionGeneral = () => {
<Separator />
- <Grid gap={2} css={sectionSpacing}>
+ <Grid gap={2} css={sectionSpacing} justify={"start"}>
<Label>Favicon</Label>
<Grid flow="column" gap={3}>
<Image
@@ -150,7 +151,7 @@ export const SectionGeneral = () => {
<Grid gap={2}>
<Text color="subtle">
- Upload a 32 x 32 px image to display in browser tabs.
+ Upload a square image to display in browser tabs.
</Text>
<ImageControl onAssetIdChange={handleSave("faviconAssetId")}>
<Button css={{ justifySelf: "start" }}>Upload</Button>
diff --git a/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx b/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
index 154079140c..23d15c2f1f 100644
--- a/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
+++ b/fixtures/webstudio-cloudflare-template/app/routes/_index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx b/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
index 43cf209571..dcfca65379 100644
--- a/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
+++ b/fixtures/webstudio-custom-template/app/routes/[script-test]._index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx b/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx
index 686b00e556..b2fbca6b23 100644
--- a/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx
+++ b/fixtures/webstudio-custom-template/app/routes/[world]._index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-custom-template/app/routes/_index.tsx b/fixtures/webstudio-custom-template/app/routes/_index.tsx
index 154079140c..23d15c2f1f 100644
--- a/fixtures/webstudio-custom-template/app/routes/_index.tsx
+++ b/fixtures/webstudio-custom-template/app/routes/_index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
index 154079140c..23d15c2f1f 100644
--- a/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-edge-functions/app/routes/_index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
index 154079140c..23d15c2f1f 100644
--- a/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-netlify-functions/app/routes/_index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
index a07511214d..21205407d9 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[_route_with_symbols_]._index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
index 21ddfaba6b..ec1967ffdb 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[form]._index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx
index e99f5f3f69..ec800825b4 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[heading-with-id]._index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
index 24f694240c..511b3f043e 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[nested].[nested-page]._index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
index 591b2f3b29..daa861e4a1 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[radix]._index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx b/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
index b66ca97a20..68cd17874a 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/[resources]._index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
index 154079140c..23d15c2f1f 100644
--- a/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
+++ b/fixtures/webstudio-remix-vercel/app/routes/_index.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/packages/cli/templates/defaults/app/route-templates/html.tsx b/packages/cli/templates/defaults/app/route-templates/html.tsx
index 0b9b81247b..e2ab0912cd 100644
--- a/packages/cli/templates/defaults/app/route-templates/html.tsx
+++ b/packages/cli/templates/defaults/app/route-templates/html.tsx
@@ -186,24 +186,15 @@ export const links: LinksFunction = () => {
rel: "icon",
href: imageLoader({
src: favIconAsset.name,
- width: 128,
+ // width,height must be multiple of 48 https://developers.google.com/search/docs/appearance/favicon-in-search
+ width: 144,
+ height: 144,
+ fit: "pad",
quality: 100,
format: "auto",
}),
type: undefined,
});
- } else {
- result.push({
- rel: "icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
-
- result.push({
- rel: "shortcut icon",
- href: "/favicon.ico",
- type: "image/x-icon",
- });
}
for (const asset of pageFontAssets) {
diff --git a/packages/image/src/image-loaders.ts b/packages/image/src/image-loaders.ts
index 40e3e76fa2..78b94c4cdb 100644
--- a/packages/image/src/image-loaders.ts
+++ b/packages/image/src/image-loaders.ts
@@ -36,6 +36,14 @@ export const createImageLoader =
searchParams.set("quality", quality.toString());
searchParams.set("format", format ?? "auto");
+ if (props.format !== "raw" && props.height != null) {
+ searchParams.set("height", props.height.toString());
+ }
+
+ if (props.format !== "raw" && props.fit != null) {
+ searchParams.set("fit", props.fit);
+ }
+
// Cloudflare docs say that we don't need to urlencode the path params
return `${imageBaseUrl}${src}?${searchParams.toString()}`;
};
diff --git a/packages/image/src/image-optimize.ts b/packages/image/src/image-optimize.ts
index 46e94b015e..c52dbfe251 100644
--- a/packages/image/src/image-optimize.ts
+++ b/packages/image/src/image-optimize.ts
@@ -92,6 +92,8 @@ export type ImageLoader = (
quality: number;
src: string;
format?: "auto";
+ height?: number;
+ fit?: "pad";
}
| { src: string; format: "raw" }
) => string;