๋ณธ๋ฌธ์œผ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

[Step by Step Tutorial] 08. Blogging

Blogging

์ด์ œ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์—†์ด ์–ด๋–ป๊ฒŒ ๋ธ”๋กœ๊ทธ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š”์ง€ ๊ถ๊ธˆํ•  ๊ฒƒ์ด๋‹ค. Jekyll ์Šคํƒ€์ผ์—์„œ ์˜ค๋กœ์ง€ text ํŒŒ์ผ๋งŒ์œผ๋กœ bloggingํ•˜๋Š” ๊ฒƒ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.


Posts#


๋ธ”๋กœ๊ทธ ํฌ์ŠคํŠธ๋Š” _posts ๋ผ๋Š” ํด๋”์— ์žˆ๋‹ค. ํฌ์ŠคํŠธ์˜ ํŒŒ์ผ๋ช…์€ ํŠน๋ณ„ํ•œ ํฌ๋งท์„ ๊ฐ€์ง€๋Š”๋ฐ ๋ฐœํ–‰์ผ, ์ œ๋ชฉ, ํ™•์žฅ์ž ์ด๋‹ค.

์ฒซ ํฌ์ŠคํŠธ๋ฅผ _posts/2018-08-20-bananas.md ๋กœ ๋งŒ๋“ค์–ด๋ณด์ž.

---layout: postauthor: jill---A banana is an edible fruit โ€“ botanically a berry โ€“ produced by several kindsof large herbaceous flowering plants in the genus Musa.
In some countries, bananas used for cooking may be called "plantains",distinguishing them from dessert bananas. The fruit is variable in size, color,and firmness, but is usually elongated and curved, with soft flesh rich instarch covered with a rind, which may be green, yellow, red, purple, or brownwhen ripe.

์ด๊ฒƒ์€ ์–ด๋–ป๊ฒŒ ๋ณด๋ฉด about.md ํŒŒ์ผ๊ณผ ๋น„์Šทํ•ด ๋ณด์ด๋Š”๋ฐ, author ๋ผ๋Š” ์ปค์Šคํ…€ ๋ณ€์ˆ˜๊ฐ€ ์žˆ๊ณ (๊ผญ ํ•„์š”ํ•œ ๊ฒƒ์€ ์•„๋‹ˆ๊ณ  creator ๋ผ๋Š” ์ด๋ฆ„์œผ๋กœ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ๋‹ค.) layout ์ด ๋‹ค๋ฅด๋‹ค.


Layout#


post ๋ผ๋Š” ๋ ˆ์ด์•„์›ƒ์ด ์—†๊ธฐ ๋•Œ๋ฌธ์—, _layouts/post.html ์„ ๋งŒ๋“ค ํ•„์š”๊ฐ€ ์žˆ๋‹ค.

---layout: default---<h1>{{ page.title }}</h1><p>{{ page.date | date_to_string }} - {{ page.author }}</p>
{{ content }}

์ด๊ฒƒ์€ ๋ ˆ์ด์•„์›ƒ์˜ ์ƒ์†์˜ ์˜ˆ์ด๋‹ค. post ๋ ˆ์ด์•„์›ƒ์€ title , date , author , content ๋ฅผ ํ‘œ์‹œํ•˜๊ณ  ์ด๊ฒƒ์€ default ๋ ˆ์ด์•„์›ƒ์œผ๋กœ ๊ฐ์‹ธ์ง„๋‹ค.

๋˜ํ•œ date_to_string ํ•„ํ„ฐ๋Š” ๋‚ ์งœ๋ฅผ ๋ณด๊ธฐ ์ข‹์€ ํ˜•์‹์œผ๋กœ ํ‘œ์‹œํ•ด์ค€๋‹ค.


List posts#


ํ˜„์žฌ blog ํฌ์ŠคํŠธ๋“ค์„ navigateํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์—†๋‹ค. ์ „ํ˜•์ ์œผ๋กœ ๋ธ”๋กœ๊ทธ๋Š” ๋ชจ๋“  ํฌ์ŠคํŠธ๋ฅผ๋ฆฌ์ŠคํŠธํ•˜๋Š” ํŽ˜์ด์ง€๋ฅผ ๊ฐ–๊ณ  ์žˆ๋‹ค.

Jekyll์—์„œ๋Š” ํฌ์ŠคํŠธ๋“ค์„ site.posts ๋กœ ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋‹ค.

blog.html ์„ ๋ฃจํŠธ ๋””๋ ‰ํ† ๋ฆฌ์— ๋งŒ๋“ ๋‹ค.

---layout: defaulttitle: Blog---<h1>Latest Posts</h1>
<ul>  {% for post in site.posts %}    <li>      <h2><a href="{{ post.url }}">{{ post.title }}</a></h2>      <p>{{ post.excerpt }}</p>    </li>  {% endfor %}</ul>

์ด ์ฝ”๋“œ์—์„œ ์œ ์˜ํ•  ๋ถ€๋ถ„์€

  • post.url ์€ ํฌ์ŠคํŠธ์˜ output path๋ฅผ Jekyll์ด ์ฐพ์•„์ค€๋‹ค.

  • post.title ์€ ํฌ์ŠคํŠธ์˜ ํŒŒ์ผ ์ด๋ฆ„์—์„œ title ์„ ๊ฐ€์ ธ์˜ค๋Š”๋ฐ front matter์˜ title ์œผ๋กœ override ํ•  ์ˆ˜ ์žˆ๋‹ค.

  • post.excerpt ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ์ฝ˜ํ…์ธ ์˜ ์ฒซ ๋ฒˆ์งธ ๋‹จ๋ฝ์„ ๊ฐ€์ ธ์˜จ๋‹ค.

๋˜ํ•œ ์šฐ๋ฆฌ๋Š” ๊ธฐ๋ณธ ํŽ˜์ด์ง€์—์„œ๋ถ€ํ„ฐ Blog ํŽ˜์ด์ง€๋กœ ๊ฐˆ ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์ด ๋„ค๋น„๊ฒŒ์ด์…˜์— ์ถ”๊ฐ€๋˜์–ด์•ผ ํ•˜๋ฏ€๋กœ _data/navigation.yml ํŒŒ์ผ์— blog page๋ฅผ ์œ„ํ•œ ์—”ํŠธ๋ฆฌ๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค .

- name: Home  link: /- name: About  link: /about.html- name: Blog  link: /blog.html

More posts#


blog์— ์—ฌ๋Ÿฌ ํฌ์ŠคํŠธ๋ฅผ ์ถ”๊ฐ€ํ•ด๋ณธ๋‹ค.

_posts/2018-08-21-apples.md

---layout: postauthor: jill---An apple is a sweet, edible fruit produced by an apple tree.Apple trees are cultivated worldwide, and are the most widely grown species inthe genus Malus. The tree originated in Central Asia, where its wild ancestor,Malus sieversii, is still found today. Apples have been grown for thousands ofyears in Asia and Europe, and were brought to North America by Europeancolonists.

_posts/2018-08-22-kiwifruit.md:

---layout: postauthor: ted---Kiwifruit (often abbreviated as kiwi), or Chinese gooseberry is the edibleberry of several species of woody vines in the genus Actinidia.The most common cultivar group of kiwifruit is oval, about the size of a largehen's egg (5โ€“8 cm (2.0โ€“3.1 in) in length and 4.5โ€“5.5 cm (1.8โ€“2.2 in) indiameter). It has a fibrous, dull greenish-brown skin and bright green orgolden flesh with rows of tiny, black, edible seeds. The fruit has a softtexture, with a sweet and unique flavor.

http://localhost:4000๋ฅผ ์—ด์–ด ํ™•์ธํ•ด๋ณธ๋‹ค.