[feat] solution/site,nginx: 발행본 목록 페이지와 루트 llms.txt — 크롤 경로를 둘로 늘린다
서치콘솔 URL 검사(2026-09-07, /s/stay): "참조 페이지: 감지된 페이지 없음". 색인은 됐는데 이 호스트의 어떤 페이지도 발행본을 가리키지 않아, 크롤러가 발행본에 닿는 길이 사이트맵 하나뿐이었다. 사이트맵은 "이런 주소가 있다"만 말하고 볼 가치가 있는지는 말하지 않는다 — 그래서 색인은 되고 순위는 0인 상태가 됐다. 랜딩의 쇼케이스는 API 를 fetch 해 그리는 클라이언트 렌더라(ShowcaseGrid.tsx) JS 를 실행하지 않는 크롤러에게는 없는 링크다. 그래서 정적 HTML 로 따로 굽는다. - seo/directory.ts: `/s/` 목록 페이지(CollectionPage + ItemList LD)와 루트 llms.txt. 목록의 제목은 payload 가 아니라 **구운 index.html 의 <title>** 에서 읽는다 — 발행은 바뀐 사이트 하나만 굽기 때문에 payload 로 만들면 나머지가 슬러그로 떨어진다 - prerender.ts: 사이트맵에 랜딩과 목록 페이지를 추가. 목록 주소는 끝 슬래시가 있어야 한다 — nginx 의 `location ^~ /s/` 가 슬래시로만 잡고, 없으면 사장님 앱으로 떨어진다 - nginx: `location ^~ /s/` 에 `index index.html`. try_files 첫 인자가 끝 슬래시면 nginx 가 디렉토리 검사로 읽고 거기서 멈춰 403 이 된다(=404 로도 안 떨어진다) ★ 루트 llms.txt 의 기대치: 구글은 안 쓴다고 공식 확인했고(2025-07 Illyes) 크롤러 트래픽으로도 거의 안 잡힌다(90일 5억 방문 중 408건). 두는 이유는 에이전트 경로 하나다 — 사용자가 AI 에게 "이 사이트 봐줘" 할 때의 fetch 는 봇 집계에 안 잡힌다. 비용이 함수 하나라 채택되면 이미 있는 쪽을 택했다. 발행본별 llms.txt 는 그대로다. 검증: tsc(solution/site) 통과 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019fteiJNvAEbTnUKq8fSqoj
This commit is contained in:
1 parent
34e5932fbc
commit
9aa93b282c
4 files changed
+203
-5
No files matched your search
@@ -24,8 +24,11 @@ import {
|
||||
homeMeta,
|
||||
renderHead,
|
||||
renderLlmsTxt,
|
||||
renderRootLlmsTxt,
|
||||
renderRootRobotsTxt,
|
||||
renderSiteIndex,
|
||||
renderSiteUrlset,
|
||||
type DirectoryEntry,
|
||||
type SiteEntry,
|
||||
verifyGeo,
|
||||
verifyJsonLd,
|
||||
@@ -510,7 +513,7 @@ function writeRootMachineFiles(outRoot: string, origin: string) {
|
||||
const sitesDir = join(outRoot, SITE_DIR);
|
||||
if (!existsSync(sitesDir)) return;
|
||||
|
||||
const entries: SiteEntry[] = readdirSync(sitesDir, {withFileTypes: true})
|
||||
const sites: DirectoryEntry[] = readdirSync(sitesDir, {withFileTypes: true})
|
||||
.filter((entry) => entry.isDirectory())
|
||||
.map((entry) => ({slug: entry.name, file: join(sitesDir, entry.name, 'index.html')}))
|
||||
// index.html 이 없으면 발행이 끝나지 않은(또는 실패한) 디렉토리다. 사이트맵에 넣지 않는다.
|
||||
@@ -521,21 +524,37 @@ function writeRootMachineFiles(outRoot: string, origin: string) {
|
||||
// 전부 "대체 페이지(적절한 표준 태그가 있음)" 로 분류했다 — 색인은 되는데 제출분은
|
||||
// 0건으로 보이는, 눈으로 원인을 못 찾는 종류다.
|
||||
loc: joinUrl(origin, SITE_DIR, entry.slug),
|
||||
// 제목은 구운 HTML 에서 읽는다. payload 에서 가져오면 이번 실행분만 이름이 있고
|
||||
// 나머지는 슬러그로 떨어진다 — 발행은 바뀐 사이트 하나만 굽기 때문이다.
|
||||
title: readTitle(entry.file) || entry.slug,
|
||||
// 페이지는 그 사이트를 구울 때마다 다시 쓰인다 — 파일 mtime 이 곧 마지막 발행 시각이다.
|
||||
lastmod: statSync(entry.file).mtime.toISOString(),
|
||||
}))
|
||||
.sort((a, b) => a.loc.localeCompare(b.loc));
|
||||
|
||||
// ★ 오리진 루트(랜딩)도 담는다. 이 호스트에 들어오는 링크가 없어 크롤러의 유일한 문이
|
||||
// 사이트맵인데, 정작 그 문을 여는 첫 페이지가 빠져 있었다.
|
||||
entries.unshift({loc: origin + '/'});
|
||||
// ★ `/s/` 목록 페이지. 크롤러가 발행본에 닿는 두 번째 경로다 —
|
||||
// 사이트맵만 있을 때 서치콘솔은 "참조 페이지: 감지된 페이지 없음" 이라고 답했다.
|
||||
// ★ 주소에 끝 슬래시가 있어야 한다 — nginx 의 `location ^~ /s/` 가 슬래시로만 잡는다.
|
||||
const indexUrl = joinUrl(origin, SITE_DIR) + '/';
|
||||
writeFileSync(join(sitesDir, 'index.html'), renderSiteIndex(origin, indexUrl, sites), 'utf-8');
|
||||
|
||||
// 사이트맵에는 랜딩·목록 페이지도 담는다. 랜딩은 이 호스트의 첫 페이지이고,
|
||||
// 목록은 발행본 전부로 이어지는 허브다 — 둘 다 크롤러가 먼저 열어야 하는 자리다.
|
||||
const entries: SiteEntry[] = [{loc: origin + '/'}, {loc: indexUrl}, ...sites];
|
||||
|
||||
writeFileSync(join(outRoot, 'robots.txt'), renderRootRobotsTxt(origin), 'utf-8');
|
||||
writeFileSync(join(outRoot, 'sitemap.xml'), renderSiteUrlset(entries), 'utf-8');
|
||||
console.log(` ✓ 루트 robots.txt · sitemap.xml (랜딩 + 사이트 ${entries.length - 1}개)`);
|
||||
writeFileSync(join(outRoot, 'llms.txt'), renderRootLlmsTxt(origin, indexUrl, sites), 'utf-8');
|
||||
console.log(` ✓ 루트 robots.txt · sitemap.xml · llms.txt · /s/ 목록 (사이트 ${sites.length}개)`);
|
||||
writeIndexNowKey(outRoot);
|
||||
}
|
||||
|
||||
/** 구운 index.html 에서 <title> 만 꺼낸다. 파서를 붙일 값어치가 없는 한 줄짜리 일이다. */
|
||||
function readTitle(file: string): string {
|
||||
const match = /<title>([^<]*)<\/title>/.exec(readFileSync(file, 'utf-8'));
|
||||
return match ? match[1].trim() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* IndexNow 키 파일 — `https://<host>/<key>.txt` 에 키 문자열만 들어 있다.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user