как указать для всех страниц такой метадата заголовок в… · The Chat Archive
Explore claude-sonnet-4-20250514 · Anthropic LMArena Human Preference 140Kкак указать для всех страниц такой метадата заголовок в NextJS? <meta name="viewport"… Save Share Download ▾ ReportFrom a Chatbot Arena battle The same person sent this prompt to two anonymous models at once. Compare it with gemini-2.5-pro ’s answer. как указать для всех страниц такой метадата заголовок в NextJS?
AssistantCopy response В Next.js есть несколько способов добавить метатег viewport для всех страниц. Вот основные подходы:
Copy first prompt Copy first response
Other models, same or similar prompt Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Details Model claude-sonnet-4-20250514
Provider Anthropic
Model provenance As recorded by source dataset
Turns 1 (2 messages)
Language it
Added to archive Nov 16, 2026
ID 01m7jfckqyt8erp58r5ss5pex9Source & license Imported from LMArena Human Preference 140K (source ). Imported records earn no Research Points.
Upstream record: 60879cec-5fef-4e72-85b5-f6649dc1b478:a
Chiang et al., Chatbot Arena: An Open Platform for Evaluating LLMs by Human Preference (2024). LMArena 140K preference release.
License: Prompts CC-BY-4.0; outputs governed by provider terms
Dataset releases Not yet included in a published release.
1. Использование _document.js (рекомендуемый способ) Создайте файл pages/_document.js:
import { Html, Head, Main, NextScript } from 'next/document'
export default function Document() {
return (
<Html>
<Head>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
</Head>
<body>
<Main />
<NextScript />
</body>
</Html>
)
}
2. Использование next.config.js В файле next.config.js добавьте:
/** @type {import('next').NextConfig} */
const nextConfig = {
async headers() {
return [
{
source: '/(.*)',
headers: [
{
key: 'viewport',
value: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no',
},
],
},
]
},
}
module.exports = nextConfig
3. Использование _app.js с Head компонентом import Head from 'next/head'
export default function App({ Component, pageProps }) {
return (
<>
<Head>
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
</Head>
<Component {...pageProps} />
</>
)
}
Рекомендация Первый способ с _document.js является наиболее подходящим для метатегов, которые должны быть на всех страницах, поскольку _document.js отвечает за структуру HTML-документа и выполняется только на сервере.
Файл _app.js больше подходит для логики приложения, состояния и компонентов, которые должны оборачивать все страницы.
После создания _document.js перезапустите сервер разработки, чтобы изменения вступили в силу.