사이트맵 XML 생성기
URL, 우선순위, 변경 빈도로 sitemap.xml 파일을 생성합니다.
이 도구 소개
사이트맵은 검색 엔진에 웹사이트의 페이지 목록과 업데이트 주기를 알려주는 파일입니다. Sitemap XML 생성기는 공식 사이트맵 프로토콜을 준수하는 올바른 형식의 sitemap.xml 파일을 생성하여 Google, Bing 및 기타 검색 엔진이 콘텐츠를 더 효율적으로 크롤링하고 색인할 수 있도록 지원합니다. 수백 개 이상의 페이지를 보유한 대규모 웹사이트의 경우 사이트맵 없이는 검색 엔진 봇이 모든 페이지를 발견하는 데 수개월이 걸릴 수 있습니다.
이 도구를 사용하려면 웹사이트의 URL을 한 줄에 하나씩 입력한 후 각 URL에 우선순위(0.0~1.0, 1.0이 최고)를 지정하고 업데이트 빈도(매일, 주간, 월간, 연간)를 선택합니다. 이 도구는 공식 사이트맵 프로토콜을 따르는 유효한 XML 사이트맵을 즉시 생성합니다. 그 후 파일을 다운로드하여 웹 서버의 루트 디렉토리에 업로드한 후 Google Search Console과 Bing 웹마스터 도구에 제출하면 더 빠른 색인이 가능해집니다.
사이트맵은 웹사이트 구조가 복잡하거나 페이지 간 내부 링크가 부족할 때 특히 유용합니다. 좋은 사이트 아키텍처의 대체품은 아니지만 검색 엔진이 새로운 콘텐츠나 업데이트된 콘텐츠를 발견하는 데 걸리는 시간을 단축할 수 있으므로 SEO에 필수적입니다. 블로그, 전자상거래 스토어, 뉴스 사이트, 문서 포털 등 대부분의 현대적인 웹사이트는 검색 엔진에 사이트맵을 등록하면 이득을 볼 수 있습니다.
자주 묻는 질문
코드 구현
from datetime import date
from xml.etree.ElementTree import Element, SubElement, tostring
from xml.dom import minidom
def generate_sitemap(urls: list[dict]) -> str:
"""
Generate sitemap.xml string.
Each url dict: { loc, lastmod?, changefreq?, priority? }
"""
root = Element("urlset")
root.set("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9")
for entry in urls:
url_el = SubElement(root, "url")
SubElement(url_el, "loc").text = entry["loc"]
if "lastmod" in entry:
SubElement(url_el, "lastmod").text = entry["lastmod"]
if "changefreq" in entry:
SubElement(url_el, "changefreq").text = entry["changefreq"]
if "priority" in entry:
SubElement(url_el, "priority").text = str(entry["priority"])
raw = tostring(root, encoding="unicode")
dom = minidom.parseString(raw)
return dom.toprettyxml(indent=" ")
urls = [
{"loc": "https://example.com/", "lastmod": str(date.today()), "changefreq": "daily", "priority": 1.0},
{"loc": "https://example.com/about", "lastmod": str(date.today()), "changefreq": "monthly", "priority": 0.8},
{"loc": "https://example.com/contact", "lastmod": str(date.today()), "changefreq": "monthly", "priority": 0.5},
]
print(generate_sitemap(urls))
Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.