Skip to main content Link Search Menu Expand Document (external link)

permalink

Table of contents

  1. Front matter
  2. 글로벌
    1. Placeholders
    2. Built-in Style
    3. Front matter에서 permalink 지정
    4. 컬렉션
    5. 페이지

permalink는 페이지, 게시물 또는 컬렉션의 output path(출력 경로)입니다.
소스 코드의 디렉토리를 output의 디렉토리와 다르게 구성 할 수 있습니다.

Front matter

permalink 를 설정하는 가장 간단한 방법은 Front matter 을 사용하는 것입니다. Front matter 에 permalink 변수를 설정해 원하는 output path 를 지정합니다.

예를 들어, 페이지 소스 코드의 path가 /my_pages/about-me.html 이고 url 을 /about/ 으로 만드려고 합니다. 페이지의 Front matter에 다음과 같이 설정합니다:

---
permalink: /about/
---

글로벌

소스 코드의 모든 페이지에 Front matter 로 permalink 를 설정하는 것은 즐겁지 않습니다. 다행하게도, Jekyll 은 _config.yml 에 글로벌 permalink 구조를 설정할 수 있게 해줍니다.

글로벌 permalink 를 설정하려면, _config.ymlpermalink 변수를 사용합니다. Placeholder 를 사용할 수 있습니다. 예를 들면:

permalink: /:categories/:year/:month/:day/:title:output_ext


페이지와 컬렉션 (postsdrafts 제외)은 time, categories 정보가 없어서 이러한 내용들은 결과물에서 무시됩니다.
(페이지에서는 :title:basename 와 같다)

예를 들어, posts 컬렉션의 permalink 스타일이 /:categories/:year/:month/:day/:title:output_ext 일 때, 페이지와 컬렉션 (postsdrafts 제외) 에서는 /:title.html 이 됩니다.

Placeholders


다음은 사용할 수 있는 Placeholder 의 전체 목록입니다:

변수설명
year 포스트 파일명 날짜의 연도 전체 네 자리. Front matter의 date 를 통해 값을 덮어쓸 수 있다.
short_year 포스트 파일명 날짜의 연도 끝 두 자리. (00..99) Front matter의 date 를 통해 값을 덮어쓸 수 있다.
month 포스트 파일명 날짜의 월. (01..12) Front matter의 date 를 통해 값을 덮어쓸 수 있다.
i_month 포스트 파일명 날짜의 월. 자리수 채우기 없음. Front matter의 date 를 통해 값을 덮어쓸 수 있다.
short_month 세 자리 월 축약형. 예시, “Jan”.
long_month 4.0 전체 월. 예시, “January”.
day 포스트 파일명 날짜의 일. (01..31) Front matter의 date 를 통해 값을 덮어쓸 수 있다.
i_day 포스트 파일명 날짜의 일. 자리수 채우기 없음. Front matter의 date 를 통해 값을 덮어쓸 수 있다.
y_day 포스트 파일명 날짜의 서수일. 자리수 채우기 포함. (001..366)
w_year 4.0 Week year which may differ from the month year for up to three days at the start of January and end of December
week 4.0 Week number of the current year, starting with the first week having a majority of its days in January. (01..53)
w_day 4.0 숫자로 표현된 요일. 월요일부터 시작. (1..7)
short_day 4.0 세 자리 요일 축약형. 예시, “Sun”.
long_day 4.0 요일명. 예시, “Sunday”.
hour 포스트 Front matter date 의 24 시간제, 두 자리 형식 시간값. (00..23)
minute 포스트 Front matter date 의 분값. (00..59)
second 포스트 Front matter date 의 초값. (00..59)
title 파일명에 명시된 문서의 제목. Front matter의 slug 를 통해 값을 덮어쓸 수 있다.
slug 파일명에 명시된 문서 제목의 슬러그화 결과
(숫자와 글자가 아닌 모든 문자를 하이픈으로 변경함).
Front matter의 slug 로 값을 덮어쓸 수 있다.
categories 해당 포스트에 지정된 카테고리들. 만약 포스트가 여러 카테고리에 속해있다면, 계층 구조로 URL 이 생성된다 (예시. /category1/category2). 또한, Jekyll 은 URL 을 분석해서 연속된 슬래시를 자동으로 제거하기 때문에, 카테고리가 하나도 없으면, Jekyll 은 이 변수를 무시한다.

Built-in Style


편의를 위해 Jekyll 은 포스트에서 사용할 수 있는 built-in style 을 제공합니다:

permalink styleURL Template
date /:categories/:year/:month/:day/:title:output_ext
pretty /:categories/:year/:month/:day/:title/
ordinal /:categories/:year/:y_day/:title:output_ext
weekdate 4.0 /:categories/:year/W:week/:short_day/:title:output_ext
none /:categories/:title:output_ext

permalink: /:categories/:year/:month/:day/:title/ 가 아니라, 그냥 permalink: pretty 라고 입력해도 된다.


built-in permalink 스타일은 Front matter 에서는 인식되지 않습니다. 따라서, permalink: pretty 는 작동하지 않을 것입니다.

컬렉션


컬렉션 (postsdrafts 포함) 의 경우, _config.yml 에서 글로벌 permalink 를 override 할 옵션을 갖는다.

collections:
  my_collection:
    output: true
    permalink: /:collection/:name


컬렉션에서 사용할 수 있는 Placeholder 는 다음과 같습니다:

변수설명
:collection 컬렉션의 레이블.
:path 컬렉션의 디렉토리와 관련된 문서 경로 (파일명 포함)
:name 모든 공백과 비-알파벳 문자를 하이픈으로 교체한 문서의 파일명.
:title 만약 문서의 Front matterslug 가 있다면, :title 템플릿 변수는 이 값을 사용한다; 만약 존재하지 않으면 :title:name 와 동일하며, 슬러그는 파일명으로부터 생성된다.
:output_ext output file 의 확장자. (기본적으로 포함되어 있으며, 일반적으로 불필요하다.)

페이지


페이지에서는, 글로벌 permalink를 덮어쓰려면 Front matter을 사용해야만 합니다.
그리고 만일 _config.yml 에서 Front matter defaults를 통해 permalink가 설정되면 그것은 무시될 것이다.

페이지에서 사용할 수 있는 Placeholder 는 다음과 같습니다:

변수설명
:path 사이트의 소스 디렉토리와 관련된 페이지 경로 ( 파일명 제외 )
:basename 페이지의 파일명
:output_ext output file의 확장자. (기본적으로 포함되어 있으며, 일반적으로 불필요하다.)