Build a beautiful and simple website in literally minutes. Demo at http://deanattali.com/beautiful-jekyll
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

284 lines
12 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
9 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
9 years ago
7 years ago
  1. # Beautiful-Jekyll Theme (beautiful-jekyll-theme gem)
  2. [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.me/daattali/20)
  3. [![Gem Version](https://badge.fury.io/rb/beautiful-jekyll-theme.svg)](https://badge.fury.io/rb/beautiful-jekyll-theme)
  4. > *Copyright 2016 [Dean Attali](http://deanattali.com)*
  5. **Beautiful-Jekyll** is a ready-to-use Jekyll theme to help you create an awesome website quickly. Perfect for personal blogs or simple project websites, with a focus on responsive and clean design. You can look at [my personal website](http://deanattali.com) to see it in use, or see examples of websites other people created using this theme [here](https://github.com/daattali/beautiful-jekyll#showcased-users-success-stories).
  6. **This theme was developed for non-commerical purposes. For commerical usage, or if you enjoy this theme, please consider [supporting me](https://www.paypal.me/daattali/20) for the development and continuous maintenance of this template.**
  7. <p align="center">
  8. <a href="https://www.paypal.me/daattali">
  9. <img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" />
  10. </a>
  11. </p>
  12. ![Screenshot](./screenshot.png)
  13. ## Prerequisites
  14. To use this theme's gem, you need to first have a functioning Jekyll website. If you don't, there are many resources online for how to set up a Jekyll site. Here are the basic commands to get a minimal Jekyll site set up in Ubuntu:
  15. ```
  16. $ sudo apt-get update
  17. $ sudo apt-get install ruby ruby-dev make gcc
  18. $ sudo gem install jekyll bundler
  19. $ jekyll new ~/mysite
  20. ```
  21. ## Installation
  22. To use the Beautiful-Jekyll theme, add this line to your Jekyll site's `Gemfile`:
  23. ```ruby
  24. gem "beautiful-jekyll-theme", "1.1.1"
  25. ```
  26. Then add this line to your Jekyll site's `_config.yml`:
  27. ```yaml
  28. theme: beautiful-jekyll-theme
  29. ```
  30. And finally execute:
  31. ```
  32. $ bundle
  33. ```
  34. To preview your site, run `bundle exec jekyll serve` (optionally with the `--host 0.0.0.0` flag if needed) and open your browser at `http://localhost:4000`.
  35. ## Usage
  36. Using Beautiful-Jekyll is very simple, but you should take a few minutes to read through the features it supports to learn how to use it.
  37. ### Adding content
  38. You can now start adding pages to your site. Beautiful-Jekyll supports three layouts: `post`, `page`, and `minimal`. In order to use Beautiful-Jekyll's template, a page must have its `layout` parameter set to one of these options in the YAML.
  39. Any blog posts (pages under the `_posts` directory) should use the `post` layout, while most other pages should use the `page` layout. You can use the `minimal` layout if you want a page with minimal styling, without the bulky navigation bar and footer.
  40. Instead of remembering to manually add the layout parameter to every page's YAML, I recommend you add the following lines to your `_config.yml` so that all blog posts will automatically have layout `post` and all other pages will have layout `page`:
  41. ```yaml
  42. defaults:
  43. -
  44. scope:
  45. path: ""
  46. type: "posts"
  47. values:
  48. layout: "post"
  49. -
  50. scope:
  51. path: ""
  52. values:
  53. layout: "page"
  54. ```
  55. ### Adding an index page
  56. Feel free to create the index page (homepage) of your site however you'd like. If you want to have an index page similar to the one at [deanattali.com](http://deanattali.com), then create `index.html` as follows:
  57. ```html
  58. ---
  59. layout: page
  60. title: My Website
  61. subtitle: Some short description of my site
  62. ---
  63. <div class="posts-list">
  64. {% for post in paginator.posts %}
  65. <article class="post-preview">
  66. <a href="{{ post.url }}">
  67. <h2 class="post-title">{{ post.title }}</h2>
  68. {% if post.subtitle %}
  69. <h3 class="post-subtitle">{{ post.subtitle }}</h3>
  70. {% endif %}
  71. </a>
  72. <p class="post-meta">
  73. Posted on {{ post.date | date: "%B %-d, %Y" }}
  74. </p>
  75. <div class="post-entry">
  76. {{ post.excerpt | strip_html | xml_escape | truncatewords: 50 }}
  77. {% assign excerpt_word_count = post.excerpt | number_of_words %}
  78. {% if post.content != post.excerpt or excerpt_word_count > 50 %}
  79. <a href="{{ post.url }}" class="post-read-more">[Read&nbsp;More]</a>
  80. {% endif %}
  81. </div>
  82. {% if post.tags.size > 0 %}
  83. <div class="blog-tags">
  84. Tags:
  85. {{ post.tags | join: ", " }}
  86. </div>
  87. {% endif %}
  88. </article>
  89. {% endfor %}
  90. </div>
  91. {% if paginator.total_pages > 1 %}
  92. <ul class="pager main-pager">
  93. {% if paginator.previous_page %}
  94. <li class="previous">
  95. <a href="{{ paginator.previous_page_path | replace: '//', '/' }}">&larr; Newer Posts</a>
  96. </li>
  97. {% endif %}
  98. {% if paginator.next_page %}
  99. <li class="next">
  100. <a href="{{ paginator.next_page_path | replace: '//', '/' }}">Older Posts &rarr;</a>
  101. </li>
  102. {% endif %}
  103. </ul>
  104. {% endif %}
  105. ```
  106. You'll also need to add these lines to your `_config.yml` because the code above uses pagination:
  107. ```yaml
  108. paginate: 5
  109. gems:
  110. - jekyll-paginate
  111. ```
  112. Make sure there is no `index.md` file (if there is one, then delete it).
  113. ### Creating a navigation bar
  114. Add these lines to your `_config.yml` file to get a demo navigation bar:
  115. ```yaml
  116. navbar-links:
  117. Home: ""
  118. About Me: "aboutme"
  119. Resources:
  120. - Beautiful Jekyll: "http://deanattali.com/beautiful-jekyll/"
  121. - Learn markdown: "http://www.markdowntutorial.com/"
  122. - GitHub Pages: "https://pages.github.com/"
  123. Author's home: "http://deanattali.com"
  124. ```
  125. Change these values to match the pages on your site. Each menu item is composed of a `key:value` pair, where the `key` is the text that shows up in the navigation bar, and `value` is the URL to link to. The URL can either be the name of a page on your site (eg. `""` will go to your homepage, `aboutme` will go to a page called `aboutme` on your site), or a URL to an external site beginning in `http`. If you want to define sub-menus, use the format that the `Resources` menu is using in the sample code above.
  126. #### Displaying an image in the navigation bar
  127. You can add an image to the middle of the navigation bar by defining the `avatar` parameter in `_config.yml`. The image should be a square (width = height). This image will disappear once the user scrolls down in the page.
  128. ```yaml
  129. avatar: "/path/to/image.png"
  130. ```
  131. You can also place an image in the top-left corner of the navigation bar instead of your website's title. This is done with the `title-img` parameter in `_config.yml`:
  132. ```yaml
  133. title-img: "/path/to/image.png"
  134. ```
  135. ### Add your name/email/social media links to the footer
  136. You can add contact information and social media links in the footer. They will be displayed as nice little logos, to give the footer a clean feel. Add the following to your `_config.yml` file:
  137. ```yaml
  138. author:
  139. name: Some Person
  140. email: "youremail@domain.com"
  141. facebook: yourname # eg. daattali
  142. github: yourname # eg. daattali
  143. twitter: yourname # eg. daattali
  144. telephone: yourphone # eg. +14159998888
  145. reddit: yourname # eg. daattali
  146. google-plus: +yourname # eg. +DeanAttali or 109424658772469020925
  147. linkedin: yourname # eg. daattali
  148. xing: yourname # eg. daattali
  149. stackoverflow: yourlink # eg. "3943160/daattali"
  150. snapchat: yourname # eg. daattali
  151. instagram: yourname # eg. daattali
  152. youtube: yourlink # eg. user/daattali or channel/daattali
  153. spotify: yourname # eg. daattali
  154. ```
  155. Remove the lines that you don't want to display in the footer, and change `yourname` to the correct values in the links you want to keep.
  156. #### Add an RSS feed link to the footer
  157. You can add an icon that will link to an RSS feed of your blog by including the following parameter in `_config.yml`:
  158. ```yaml
  159. rss-footer: true
  160. ```
  161. #### Add your website's name to the footer
  162. After all the contact info links, you can also add the name of your website by defining the `url-pretty` parameter in `_config.yml`:
  163. ```yaml
  164. url-pretty: "MyWebsite.com"
  165. ```
  166. ### Buttons for sharing blog posts on social media
  167. By default, every blog post will have buttons at the bottom for sharing the page on Twitter, Facebook, LinkedIn, and Google+. If you want to disable these buttons, add these lines to your `_config.yml`:
  168. ```yaml
  169. share-links-active:
  170. twitter: false
  171. facebook: false
  172. google: false
  173. linkedin: false
  174. ```
  175. These settings will remove all four buttons. You can use `true` instead of `false` for any buttons that you want to keep.
  176. ### Allowing users to leave comments
  177. If you want to enable comments on your site, Beautiful-Jekyll supports the [Disqus](https://disqus.com/) comments plugin. To use it, simply sign up to Disqus and add your Disqus shortname (**not** the userid) to the `disqus` parameter in `_config.yml`:
  178. ```yaml
  179. disqus: yourshortname
  180. ```
  181. ### Adding Google Analytics to track page views
  182. Beautiful-Jekyll lets you easily add Google Analytics to all your pages. This will allow you to track all sorts of information about visits to your website, such as how many times each page is viewed and where (geographically) your users come from. To add Google Analytics, simply sign up to [Google Analytics](http://www.google.com/analytics/) to obtain your Google Tracking ID, and add this tracking ID to the `google_analytics` parameter in `_config.yml`:
  183. ```yaml
  184. google_analytics: yourid
  185. ```
  186. ### YAML parameter you can use to personalize each page
  187. These are all the parameters you can place inside a page's YAML front matter that Beautiful-Jekyll supports.
  188. Parameter | Description
  189. ----------- | -----------
  190. layout | What type of page this is (default is `blog` for blog posts and `page` for other pages. You can use `minimal` if you don't want a header and footer).
  191. title | Page or blog post title.
  192. subtitle | Short description of page or blog post that goes under the title.
  193. bigimg | Include a large full-width image at the top of the page. You can either give the path to a single image, or provide a list of images to cycle through (see [my personal website](http://deanattali.com/) as an example).
  194. comments | Only applicable if the `disqus` parameter is set in the `_config.yml` file. All blog posts automatically have comments enabled. To enable comments on a specific page, use `comments: true`; to turn comments off for a specific blog post, use `comments: false`.
  195. social-share | If you don't want to show buttons to share a blog post on social media, use `social-share: false` (this feature is turned on by default).
  196. share-img | If you want to specify an image to use when sharing the page on Facebook or Twitter, then provide the image's full URL here.
  197. image | If you want to add a personalized image to your blog post that will show up next to the post's excerpt and on the post itself, use `image: /path/to/img.png`.
  198. js | List of local JavaScript files to include in the page (eg. `/js/mypage.js`)
  199. ext-js | List of external JavaScript files to include in the page (eg. `//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js`)
  200. css | List of local CSS files to include in the page
  201. ex-css | List of external CSS files to include in the page
  202. googlefonts | List of Google fonts to include in the page (eg. `["Monoton", "Lobster"]`)
  203. ## Contributions
  204. If you find anything wrong or would like to contribute in any way, feel free to submit a pull request/open an issue [on GitHub](https://github.com/daattali/beautiful-jekyll), or [send me a message](http://deanattali.com/contact).
  205. Thank you to [all contributors](https://github.com/daattali/beautiful-jekyll/graphs/contributors). Special thanks to the following people with non-trivial contributions (in chronological order): [@hristoyankov](https://github.com/hristoyankov), [@jamesonzimmer](https://github.com/jamesonzimmer), [@XNerv](https://github.com/XNerv), [@epwalsh](https://github.com/epwalsh), [@rtlee9](https://github.com/rtlee9).
  206. ## Credits
  207. This template was not made entirely from scratch. I would like to give special thanks to:
  208. - [Barry Clark](https://github.com/barryclark) and his project [Jekyll Now](https://github.com/barryclark/jekyll-now), from whom I've taken several ideas and code snippets, as well as some documenation tips.
  209. - [Iron Summit Media](https://github.com/IronSummitMedia) and their project [Bootstrap Clean Blog](https://github.com/IronSummitMedia/startbootstrap-clean-blog), from which I've used some design ideas and some of the templating code for posts and pagination.
  210. I'd also like to thank [Dr. Jekyll's Themes](http://drjekyllthemes.github.io/), [Jekyll Themes](http://jekyllthemes.org/), and another [Jekyll Themes](http://jekyllrc.github.io/jekyllthemes/) for featuring Beautiful Jekyll in their Jekyll theme directories.