fix(seo): noindex 페이지에 JSON-LD 구조화 데이터 미렌더#57
Conversation
pageType="profile"을 전달하는 레이아웃은 AboutLayout(/about)과
PortfolioLayout(/portfolio) 두 개다. Person JSON-LD의 url이
${SITE.website}/about로 고정돼 있어, noindex 페이지인 /portfolio에도
Person 구조화 데이터가 렌더되고 url이 잘못 /about을 가리켰다.
robots prop에 noindex가 포함되면 JSON-LD를 렌더하지 않도록 게이팅했다.
검색엔진은 색인하지 않을 페이지의 구조화 데이터를 사용하지 않으므로,
portfolio 전용 분기가 아닌 일반 규칙으로 처리해 향후 추가될 noindex
페이지에도 자동 적용된다. /about의 출력은 변경되지 않는다.
There was a problem hiding this comment.
Code Review
This pull request modifies src/layouts/Layout.astro to prevent the generation of JSON-LD structured data on pages where the robots meta tag is set to 'noindex'. It also adds a clarifying comment regarding the author's profile URL. The review feedback suggests improving the detection of the 'noindex' state by using a case-insensitive regular expression that also accounts for the 'none' keyword, ensuring more robust behavior across different meta tag configurations.
HTML robots 디렉티브는 대소문자를 구분하지 않으며 none은
noindex + nofollow와 동등하다. 기존 includes("noindex")는 none이나
대문자 표기를 놓쳐, 그런 robots 값을 쓴 페이지가 크롤러에는
noindex이면서 구조화 데이터는 계속 렌더되는 불일치가 있었다.
robots 값은 meta 태그에 그대로 출력되므로, 동일 기준으로 noindex를
판정하도록 /noindex|none/i 정규식으로 교체한다.
Code Review — PR #57Overview이 PR은 Code Quality & Style ✅
Potential Issues1. Regex 경계 처리 (Minor) const noindex = /noindex|none/i.test(robots ?? "");
2.
Performance ✅
Security ✅
Verification ✅PR 설명에 따르면 빌드 검증이 CLAUDE.md의 가이드라인(
Summary변경 범위가 단일 파일, 최소 수정(+17/-7)이고, 수정 목적과 접근 방식이 명확하게 문서화되어 있습니다. 버그 수정으로서 적절하며 회귀 위험이 낮습니다. Regex 경계 처리는 선택적 개선사항으로, 현재 구현도 충분히 안전합니다. Approve 권고합니다. |
|
리뷰 감사합니다. 두 지적사항 검토 결과를 공유합니다. 1. Regex 경계 처리 — 현재 표준 robots 디렉티브( 2.
→ 코드 변경 없이 현 상태로 머지 가능합니다. |
Description
pageType="profile"을 전달하는 레이아웃은AboutLayout(/about)과PortfolioLayout(/portfolio) 두 개입니다.Layout.astro의 Person JSON-LD는url이${SITE.website}/about로 고정돼 있어,noindex페이지인/portfolio에도 Person 구조화 데이터가 렌더되고url이 잘못/about을 가리켰습니다.robotsprop에noindex가 포함되면 JSON-LD 자체를 렌더하지 않도록 게이팅했습니다. 검색엔진은 색인하지 않을 페이지의 구조화 데이터를 사용하지 않으므로,/portfolio전용 분기가 아닌 일반 규칙으로 처리해 향후 추가될noindex페이지에도 자동 적용됩니다.변경 파일:
src/layouts/Layout.astro(단일 파일, +16 / −7)Types of changes
Checklist
Further comments
검토한 세 가지 방안:
url을 prop으로 전달:/portfolio가 여전히 Person 스키마를 렌더하므로url이noindex페이지를 가리키는 의미적 모순이 남습니다./portfolio에서url이/portfolio가 되어 동일한 문제. schema.orgPerson.url은 "그 인물의 정규 프로필 페이지"를 의미하므로 현재 페이지 canonical과 개념이 다릅니다.noindex페이지에서 구조화 데이터 미렌더:/portfolio는robots: "noindex, nofollow"라 구조화 데이터의 SEO 가치가 0입니다.구현 노트:
structuredData가null일 때<script>엘리먼트 자체를 조건부 렌더 —JSON.stringify(null)이"null"문자열을 출력하는 것을 방지.Person.url은${SITE.website}/about고정값을 유지(사이트 차원의 정규 프로필 URL). 다음 수정자가canonicalURL로 바꿔 버그를 재도입하지 않도록 의도 주석을 추가.검증
pnpm build통과(164 페이지 빌드,astro check타입체크 통과),pnpm lint·pnpm format통과dist/about/index.html: JSON-LD Person 존재,"url":"https://caesiumy.dev/about"— 변경 전과 동일dist/portfolio/index.html:application/ld+json0건(제거됨),og:type="profile"·robots="noindex, nofollow"메타는 영향 없이 유지Related Issue
해당 없음