Kevin Grimm
05/22/2022, 12:59 PMpublic (same level as pages):
public/
- assets/
- img/
- img1.png
- img2.png
- styles/
- static/
- favicons/
- android-chrome-192x192.png
- android-chrome-512x512.png
- apple-touch-icon.png
- favicon-16x16.png
- favicon-32x32.png
- favicon.ico
- site.webmanifest
And the relevant code
// _app.js
// imports/return*
<Head>
<meta content="width=device-width, initial-scale=1" name="viewport" />
</Head>
// _document.js
import Document, { Html, Head, Main, NextScript } from 'next/document';
class MyDocument extends Document {
render() {
return (
<Html lang="en" className="scroll-smooth">
<Head>
<link
rel="apple-touch-icon"
sizes="76x76"
href="/static/favicons/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="/static/favicons/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="/static/favicons/favicon-16x16.png"
/>
<link rel="manifest" href="/static/favicons/site.webmanifest" />
<meta name="msapplication-TileColor" content="#000000" />
<meta name="theme-color" content="#000000" />
</Head>
<Main />
<NextScript />
</Html>
);
}
}
export default MyDocument;
// index.js
<Head>
<title>Site Name</title>
<meta name="robots" content="follow, index" />
<meta
name="description"
content="Site description"
/>
<meta propetty="og:url" content="<https://websiet.com>" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="Site Name" />
<meta
property="og:description"
content="Site description"
/>
<meta property="og:title" content="Site Name" />
</Head>Derek Kershner
05/22/2022, 2:11 PM/static/favicons/favicon-32x32.png results in the browser reporting a 404?Derek Kershner
05/22/2022, 2:13 PMDevin
05/22/2022, 2:31 PMKevin Grimm
05/22/2022, 4:32 PMKevin Grimm
05/22/2022, 4:32 PM/public, though I will probably try S3 at some point if I can't find a workaroundDerek Kershner
05/22/2022, 4:34 PMnext dev?Derek Kershner
05/22/2022, 4:34 PMKevin Grimm
05/22/2022, 4:35 PMnpm run dev , which maps to sst-env -- next devDerek Kershner
05/22/2022, 4:35 PMKevin Grimm
05/22/2022, 4:35 PMKevin Grimm
05/22/2022, 4:36 PMDerek Kershner
05/22/2022, 4:36 PMpages, but pages has multiple possible locations, whereas public must be root, period.Derek Kershner
05/22/2022, 4:38 PMDerek Kershner
05/22/2022, 4:39 PMDavid Martin
05/22/2022, 7:42 PM/public is not correct for nextjs favicons.
take a look at this; https://coderrocketfuel.com/article/add-favicon-images-to-a-next-js-website
my nextjs has favicons loading properly. the /public dir contains, among others favicon-16x16.pngDavid Martin
05/22/2022, 7:44 PM/public without /static/faviconsKevin Grimm
05/22/2022, 8:38 PMKevin Grimm
05/22/2022, 8:39 PMKevin Grimm
05/22/2022, 9:20 PMpublic folder was next to pages but one level deeper than the project root (I have pages, components etc in frontend). Also regenerated favicons per that post. Still not loading in the icon but found through localhost:3000/favicon.icoKevin Grimm
05/22/2022, 9:22 PMKevin Grimm
05/22/2022, 9:43 PM