예제
KO

AMP

Hwaro는 일반 페이지와 함께 콘텐츠의 AMP(Accelerated Mobile Pages) 버전을 자동으로 생성할 수 있습니다.

동작 방식

  1. 일반 페이지를 먼저 렌더링합니다
  2. 렌더링이 끝나면 Hwaro가 각 페이지의 HTML을 읽어 AMP 호환 버전을 만듭니다
  3. AMP 페이지는 설정 가능한 경로 접두사(기본값: /amp/) 아래에 기록됩니다
  4. 캐노니컬 페이지의 <head>에 <link rel="amphtml"> 태그가 주입됩니다

설정

[amp]
enabled = true
path_prefix = "amp"
sections = ["posts"]
키 타입 기본값 설명
enabled bool false AMP 페이지 생성 활성화
path_prefix string "amp" AMP 페이지의 URL 접두사
sections array [] AMP를 생성할 섹션 (비워 두면 전체). [feeds]처럼 하위 섹션도 포함 ("posts"는 posts/2024도 포함)

변환 내용

AMP 변환기는 다음 변환을 자동으로 적용합니다:

원본 AMP 버전
<html> <html amp>
<img> width와 height가 있으면 <amp-img layout="responsive">, 없으면 <div class="amp-img-container"> 안의 <amp-img layout="fill">
<video> <amp-video layout="responsive">
<iframe> <amp-iframe layout="responsive"> (height만 있으면 layout="fixed-height"). sandbox가 없으면 기본값을 추가
<picture> <img>만 남기고(<source> 요소는 제거) 위와 같이 변환
<script> 제거. 단 JSON-LD(type="application/ld+json")와 cdn.ampproject.org에서 불러오는 스크립트는 유지
<link rel="stylesheet"> 제거. 단 AMP가 허용하는 폰트 제공자(Google Fonts, Bunny Fonts, Typekit, Font Awesome 등)는 유지
<style> 블록 하나의 <style amp-custom>으로 합침. !important와 AMP가 허용하지 않는 at-rule(@import, @layer 등)은 제거
style="..." 속성 제거
on* 이벤트 핸들러 (onclick 등) 제거
loading, decoding, fetchpriority 속성 제거 (AMP 요소는 자체 지연 로딩을 하며 이 속성들을 허용하지 않음)
상대 경로 src / href (cover.png, ../other/) AMP 사본이 한 단계 더 깊은 디렉터리에 있으므로 원본 페이지 URL 기준으로 변환

추가로 다음이 주입됩니다:

테마가 이미 <style amp-boilerplate>를 포함하고 있으면 보일러플레이트, 런타임, <style> 병합은 건너뛰지만, 빠진 확장 스크립트와 <link rel="canonical">은 여전히 추가합니다. 초안, redirect_to 페이지, render = false 페이지는 AMP 버전을 만들지 않습니다. CSP를 켜면 AMP 사본에는 CSP <meta> 태그가 붙지 않습니다.

출력 구조

/posts/hello/ 페이지가 있을 때 출력은 다음과 같습니다:

public/
  posts/hello/index.html       ← canonical (has <link rel="amphtml">)
  amp/posts/hello/index.html   ← AMP version

섹션 필터링

기본적으로 AMP 페이지는 모든 섹션에 대해 생성됩니다. sections로 대상을 제한합니다:

[amp]
enabled = true
sections = ["posts", "blog"]   # 이 섹션들(과 하위 섹션)만 AMP 버전 생성

사용자 지정 경로 접두사

[amp]
enabled = true
path_prefix = "mobile"    # /amp/posts/hello/ 대신 /mobile/posts/hello/

함께 보기