Merge remote-tracking branch 'jekyll/master' into patch-1

This commit is contained in:
Heng Kwokfu 2016-09-24 08:46:24 +08:00
commit db53213d16
85 changed files with 1165 additions and 606 deletions

View File

@ -4,18 +4,21 @@
and check.) If there is no need for certain fields like output and redirection, please delete
those headers before submitting. We know not all tickets require those steps.
Otherwise, please try to be as detailed as possible.
If you are unsure this is a bug in Jekyll, or this is a bug caused
by a plugin that isn't directly related to Jekyll, or if this is just
a generic usage question, please consider asking your question at
https://talk.jekyllrb.com where non-bug questions go.
Please make sure to mention an affinity team whose responsibilities
most closely align with your issue.
Thanks!
-->
- [ ] I believe this to be a bug, not a question about using Jekyll.
- [ ] I Updated to the latest Jekyll (or) if on Github Pages to the latest `github-pages`
- [ ] I Read the CONTRIBUTION file at https://jekyllrb.com/docs/contributing/
- [ ] I updated to the latest Jekyll (or) if on GitHub Pages to the latest `github-pages`
- [ ] I read the CONTRIBUTION file at https://jekyllrb.com/docs/contributing/
- [ ] This is a feature request.
---
@ -38,20 +41,20 @@
- [ ] I was trying to install.
- [ ] There is a broken Plugin API.
- [ ] I had an error on Github Pages, and I have not tested locally.
- [ ] I had an error on Github Pages, and Github Support said it was a Jekyll Bug.
- [ ] I had an error on Github Pages and I did not test it locally.
- [ ] I had an error on GitHub Pages, and I have reproduced it locally.
- [ ] I had an error on GitHub Pages, and GitHub Support said it was a Jekyll Bug.
- [ ] I had an error on GitHub Pages and I did not test it locally.
- [ ] I was trying to build.
- [ ] It was another bug.
## My Reproduction Steps
<!--
If this error occured on Github Pages, please try to provide us with logs,
If this error occured on GitHub Pages, please try to provide us with logs,
and look at them yourself, to determine if this is an actual Jekyll bug. In
the event you are unsure, file a ticket, however, when you do please provide
the logs (strip them of personal information.)
If you have trouble finding your logs, please email support@github.com and
they will happily help you. If you cannot find logs, please try your best to
replicate it locally because we cannot fix a problem if we do not know
@ -62,17 +65,18 @@
Insert the steps you took to for this problem to exist. Such as the
directories you created and, the full command you ran, and include any
plugins you have installed, this is very important.
If your steps are complicated, you can also submit a Github
If your steps are complicated, you can also submit a GitHub
repository (please no zips, they will be removed and rejected by maintainers,)
and just supply a command for us to reproduce it ourselves.
-->
## The Output I Wanted
<!--
<!--
Insert the output from the command. Alter it as little as you can.
The minimum should be personal information. Though we normally don't log
anything like that so there should be no need to alter it.
-->
/cc include any Jekyll affinity teams here (see https://teams.jekyllrb.com/ for more info)

View File

@ -4,8 +4,6 @@ AllCops:
Include:
- lib/**/*.rb
Exclude:
- lib/jekyll/convertible.rb
- lib/jekyll/document.rb
- lib/jekyll/renderer.rb
- bin/**/*
- benchmark/**/*
@ -18,14 +16,14 @@ Lint/UnreachableCode:
Lint/UselessAccessModifier:
Enabled: false
Metrics/AbcSize:
Max: 20
Max: 21
Metrics/ClassLength:
Exclude:
- !ruby/regexp /features\/.*.rb$/
- !ruby/regexp /test\/.*.rb$/
Max: 300
Metrics/CyclomaticComplexity:
Max: 8
Max: 9
Metrics/LineLength:
Exclude:
- !ruby/regexp /features\/.*.rb/

View File

@ -1,8 +1,31 @@
## HEAD
### Minor Enhancements
* Colorize interpolated output in logger.info (#5239)
* Site template: exclude Gemfile and Gemfile.lock in site config (#5293)
* Fix #5233: Increase our ability to detect Windows. (#5235)
* update gitignore template to ignore theme gems built by user (#5326)
* Adds ability to link to all files (#5199)
* Exclude vendor by default (#5361)
* Add ThemeAssetsReader which reads assets from a theme (#5364)
* Add bundle install to jekyll new command (#5237)
* Add absolute_url and relative_url filters. (#5399)
* Site template: remove `css/` from new site scaffolding (#5402)
### Bug Fixes
* Use jekyll-feed to generate the default site's RSS feed (#5196)
* Site#configure_theme: do not set theme unless it's a string (#5189)
* Convertible: set self.output in #render_all_layouts and #do_layout (#5337)
* Only complain about `kramdown.coderay` if it is actually in the config (#5380)
* Clarify documentation in theme gem's README template (#5376)
* Allow underscore in highlighter language (#5375)
* Site template: set empty url in config file by default (#5338)
### Site Enhancements
* Document for to_integer and inspect filters (#5185)
* Document `to_integer` and `inspect` filters (#5185)
* Fix path in the prompt (#5194)
* need subcommand build (#5190)
* Add the Jekyll Cloudinary plugin (#5183)
@ -11,23 +34,46 @@
* Remove mention of page for link tag in release post (#5214)
* fixed typo (#5226)
* Add missing comma (#5222)
* Maintain aspect ratio with height: auto; (#5254)
* Maintain aspect ratio with `height: auto;` (#5254)
* Fix a link in deployment-methods.md (#5244)
* Documentation: improve highlight in `Creating a theme` (#5249)
* Bundler isn't installed by default (#5258)
* Update troubleshooting documentation to include fix for issue with vendored gems (#5271)
* Link `--lsi` option's description to Wikipedia docs on LSI (#5274)
* Document `--profile` option on the configuration page (#5279)
* Update homepage to sync with merge of #5258 (#5287)
* Add post about Jekyll Admin initial release (#5291)
* Replace liquid highlight tag with backticks (#5262)
* Word update (#5294)
* Site documentation section links always point to https://jekyllrb.com (#5281)
* Missing `:site, :post_render` payload documentation on site (#5280)
* Site: exclude README.md and .gitignore (#5304)
* Add link to Staticman (#5224)
* Update url for OpenShift (#5320)
* [docs] add help for missing static_file e.g. on heroku (#5334)
* Add a line about updating theme-gems in the docs (#5318)
* Explain how to copy a theme's files (#5335)
* [docs] .md as default extension in examples (#5316)
* Fix small typo in docs (#5347)
* Add missing period to sentence in first paragraph. (#5372)
* added jekyll-spotify plugin (#5369)
* Add jekyll-menus to the list of plugins. (#5397)
### Development Fixes
* Update appveyor.yml and fix optional deps for Ruby x64 (#5180)
* Improve tests for Jekyll::PluginManager (#5167)
* Update Ruby versions in travis.yml (#5221)
### Bug Fixes
* Use jekyll-feed to generate the default site's RSS feed (#5196)
### Minor Enhancements
* Colorize interpolated output in logger.info (#5239)
* Avoid installing unecessary gems for site testing (#5272)
* Proposal: Affinity teams and their captains (#5273)
* Replace duplicate with postive local test in issue template (#5286)
* Update AppVeyor config. (#5240)
* Execute jekyll from clone instead of defined binary when running 'script/default-site' (#5295)
* rubocop: lib/jekyll/document.rb complexity fixes (#5045)
* Proxy a number of Convertible methods to Renderer (#5308)
* Run executable for Cucumber via Ruby instead of Shell (#5383)
* Appease Rubocop (#5381)
* remove features' directories on windows with proper access (#5389)
## 3.2.1 / 2016-08-02

View File

@ -1,5 +1,3 @@
# https://www.appveyor.com/docs/appveyor-yml
version: "{build}"
clone_depth: 10
@ -13,31 +11,24 @@ build: off
install:
- SET PATH=C:\Ruby%RUBY_FOLDER_VER%\bin;%PATH%
- bundle install --retry 5
- bundle install --retry 5 --jobs=%NUMBER_OF_PROCESSORS% --clean --path vendor\bundle
environment:
BUNDLE_WITHOUT: "benchmark:site:development"
matrix:
- RUBY_FOLDER_VER: "23"
GEMS_FOLDER_VER: "2.3.0"
TEST_SUITE: "test"
- RUBY_FOLDER_VER: "23"
GEMS_FOLDER_VER: "2.3.0"
TEST_SUITE: "cucumber"
- RUBY_FOLDER_VER: "23"
GEMS_FOLDER_VER: "2.3.0"
TEST_SUITE: "fmt"
- RUBY_FOLDER_VER: "23"
GEMS_FOLDER_VER: "2.3.0"
TEST_SUITE: "default-site"
- RUBY_FOLDER_VER: "23-x64"
GEMS_FOLDER_VER: "2.3.0"
TEST_SUITE: "test"
- RUBY_FOLDER_VER: "22"
GEMS_FOLDER_VER: "2.2.0"
TEST_SUITE: "test"
- RUBY_FOLDER_VER: "21"
GEMS_FOLDER_VER: "2.1.0"
TEST_SUITE: "test"
test_script:
@ -48,5 +39,4 @@ test_script:
cache:
# If one of the files after the right arrow changes, cache will be skipped
- C:\Ruby%RUBY_FOLDER_VER%\bin -> Gemfile,jekyll.gemspec,appveyor.yml
- C:\Ruby%RUBY_FOLDER_VER%\lib\ruby\gems\%GEMS_FOLDER_VER% -> Gemfile,jekyll.gemspec,appveyor.yml
- 'vendor\bundle -> appveyor.yml,Gemfile,jekyll.gemspec'

View File

@ -0,0 +1,25 @@
# Affinity Team Captains
**This guide is for affinity team captains.** These special people are **team maintainers** of one of our [affinity teams][] and help triage and evaluate the issues and contributions of others. You may find what is written here interesting, but its definitely not for everyone.
## Affinity teams & their captains
The Jekyll project uses [affinity teams][] to help break up the work of incoming issues and pull requests from community members. We receive a sizeable number of issues and pull requests each week; the use of affinity teams helps distribute this load across a number of specialized groups instead of pushing it all onto @jekyll/core.
## Responsibilities of Team Captains
Each affinity team has a few captains who manage the issues and pull requests for that team. When an issue or PR is opened with a `/cc` for a given affinity team, @jekyllbot automatically assigns a random affinity team captain to the issue to triage it. They have access to add labels, reassign the issue, give LGTM's, and so forth. While they do not merge PR's today, they are still asked to review PR's for parts of the codebase under their purview.
## How do I become a team captain?
Just ask! Feel free to open an issue on `jekyll/jekyll` and add `/cc @jekyll/core`. We can add you. :smile:
Alternatively, you can email or otherwise reach out to [@parkr](https://github.com/parkr) directly if you prefer the more private route.
## Ugh, I'm tired and don't have time to be a captain anymore. What now?
No sweat at all! Email [@parkr](https://github.com/parkr) and ask to be removed. Alternatively, you should be able to go to your team's page on GitHub.com (go to https://github.com/jekyll, click "Teams", click the link to your team) and change your status to either "member" or leave the team.
We realize that being a captain is no easy feat so we want to make it a great experience. As always, communicate as much as you can with us about what is working, and what isn't. Thanks for dedicating some time to Jekyll! :sparkles:
[affinity teams]: https://teams.jekyllrb.com/

View File

@ -1,7 +1,7 @@
#!/usr/bin/env ruby
STDOUT.sync = true
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w(.. lib)))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require "jekyll"
require "mercenary"

View File

@ -1,4 +1,5 @@
Before do
FileUtils.rm_rf(Paths.test_dir) if Paths.test_dir.exist?
FileUtils.mkdir_p(Paths.test_dir) unless Paths.test_dir.directory?
Dir.chdir(Paths.test_dir)
end
@ -6,7 +7,7 @@ end
#
After do
Paths.test_dir.rmtree if Paths.test_dir.exist?
FileUtils.rm_rf(Paths.test_dir) if Paths.test_dir.exist?
Paths.output_file.delete if Paths.output_file.exist?
Paths.status_file.delete if Paths.status_file.exist?
Dir.chdir(Paths.test_dir.parent)

View File

@ -90,7 +90,7 @@ end
def run_jekyll(args)
args = args.strip.split(" ") # Shellwords?
process = run_in_shell(Paths.jekyll_bin.to_s, *args, "--trace")
process = run_in_shell("ruby", Paths.jekyll_bin.to_s, *args, "--trace")
process.exitstatus.zero?
end

View File

@ -17,7 +17,7 @@ Feature: Writing themes
Scenario: A theme with SCSS
Given I have a configuration file with "theme" set to "test-theme"
And I have a css directory
And I have a "css/main.scss" page that contains "@import 'style';"
And I have a "css/main.scss" page that contains "@import 'test-theme-black';"
When I run jekyll build
Then I should get a zero exit status
And the _site directory should exist

View File

@ -55,6 +55,7 @@ module Jekyll
autoload :PostReader, "jekyll/readers/post_reader"
autoload :PageReader, "jekyll/readers/page_reader"
autoload :StaticFileReader, "jekyll/readers/static_file_reader"
autoload :ThemeAssetsReader, "jekyll/readers/theme_assets_reader"
autoload :LogAdapter, "jekyll/log_adapter"
autoload :Page, "jekyll/page"
autoload :PluginManager, "jekyll/plugin_manager"

View File

@ -71,12 +71,23 @@ module Jekyll
#
# Returns nothing.
def watch(site, options)
External.require_with_graceful_fail "jekyll-watch"
watch_method = Jekyll::Watcher.method(:watch)
if watch_method.parameters.size == 1
watch_method.call(options)
if Utils::Platforms.windows?
Jekyll.logger.warn "", "--watch arg is unsupported on Windows. "
Jekyll.logger.warn "", "If you are on Windows Bash, please see: " \
"https://github.com/Microsoft/BashOnWindows/issues/216"
else
watch_method.call(options, site)
External.require_with_graceful_fail "jekyll-watch"
watch_method = Jekyll::Watcher.method(:watch)
if watch_method.parameters.size == 1
watch_method.call(
options
)
else
watch_method.call(
options, site
)
end
end
end
end # end of class << self

View File

@ -11,6 +11,7 @@ module Jekyll
c.option "force", "--force", "Force creation even if PATH already exists"
c.option "blank", "--blank", "Creates scaffolding but with empty files"
c.option "skip-bundle", "--skip-bundle", "Skip 'bundle install'"
c.action do |args, options|
Jekyll::Commands::New.process(args, options)
@ -34,7 +35,7 @@ module Jekyll
create_site new_blog_path
end
Jekyll.logger.info "New jekyll site installed in #{new_blog_path.cyan}."
after_install(new_blog_path, options)
end
def create_blank_site(path)
@ -114,6 +115,27 @@ RUBY
def scaffold_path
"_posts/0000-00-00-welcome-to-jekyll.markdown.erb"
end
# After a new blog has been created, print a success notification and
# then automatically execute bundle install from within the new blog dir
# unless the user opts to generate a blank blog or skip 'bundle install'.
def after_install(path, options = {})
Jekyll.logger.info "New jekyll site installed in #{path.cyan}."
Jekyll.logger.info "Bundle install skipped." if options["skip-bundle"]
unless options["blank"] || options["skip-bundle"]
bundle_install path
end
end
def bundle_install(path)
Jekyll::External.require_with_graceful_fail "bundler"
Jekyll.logger.info "Running bundle install in #{path.cyan}..."
Dir.chdir(path) do
system("bundle", "install")
end
end
end
end
end

View File

@ -17,7 +17,7 @@ module Jekyll
# Handling Reading
"safe" => false,
"include" => [".htaccess"],
"exclude" => [],
"exclude" => ["vendor"],
"keep_files" => [".git", ".svn"],
"encoding" => "utf-8",
"markdown_ext" => "markdown,mkdown,mkdn,mkd,md",

View File

@ -104,7 +104,7 @@ module Jekyll
private
def modernize_coderay_config
if highlighter == "coderay"
unless @config["coderay"].empty?
Jekyll::Deprecator.deprecation_message(
"You are using 'kramdown.coderay' in your configuration, " \
"please use 'syntax_highlighter_opts' instead."

View File

@ -35,6 +35,7 @@ module Jekyll
# opts - optional parameter to File.read, default at site configs
#
# Returns nothing.
# rubocop:disable Metrics/AbcSize
def read_yaml(base, name, opts = {})
filename = File.join(base, name)
@ -58,6 +59,7 @@ module Jekyll
self.data
end
# rubocop:enable Metrics/AbcSize
def validate_data!(filename)
unless self.data.is_a?(Hash)
@ -76,18 +78,7 @@ module Jekyll
#
# Returns the transformed contents.
def transform
converters.reduce(content) do |output, converter|
begin
converter.convert output
rescue => e
Jekyll.logger.error(
"Conversion error:",
"#{converter.class} encountered an error while converting '#{path}':"
)
Jekyll.logger.error("", e.to_s)
raise e
end
end
_renderer.transform
end
# Determine the extension depending on content_type.
@ -95,7 +86,7 @@ module Jekyll
# Returns the String extension for the output file.
# e.g. ".html" for an HTML output file.
def output_ext
Jekyll::Renderer.new(site, self).output_ext
_renderer.output_ext
end
# Determine which converter to use based on this convertible's
@ -103,7 +94,7 @@ module Jekyll
#
# Returns the Converter instance.
def converters
@converters ||= site.converters.select { |c| c.matches(ext) }.sort
_renderer.converters
end
# Render Liquid in the content
@ -114,17 +105,7 @@ module Jekyll
#
# Returns the converted content
def render_liquid(content, payload, info, path)
template = site.liquid_renderer.file(path).parse(content)
template.warnings.each do |e|
Jekyll.logger.warn "Liquid Warning:",
LiquidRenderer.format_error(e, path || self.path)
end
template.render!(payload, info)
# rubocop: disable RescueException
rescue Exception => e
Jekyll.logger.error "Liquid Exception:",
LiquidRenderer.format_error(e, path || self.path)
raise e
_renderer.render_liquid(content, payload, info, path)
end
# rubocop: enable RescueException
@ -211,40 +192,10 @@ module Jekyll
#
# Returns nothing
def render_all_layouts(layouts, payload, info)
# recursively render layouts
layout = layouts[data["layout"]]
Jekyll.logger.warn(
"Build Warning:",
"Layout '#{data["layout"]}' requested in #{path} does not exist."
) if invalid_layout? layout
used = Set.new([layout])
# Reset the payload layout data to ensure it starts fresh for each page.
payload["layout"] = nil
while layout
Jekyll.logger.debug "Rendering Layout:", path
payload["content"] = output
payload["layout"] = Utils.deep_merge_hashes(layout.data, payload["layout"] || {})
self.output = render_liquid(layout.content,
payload,
info,
layout.relative_path)
# Add layout to dependency tree
site.regenerator.add_dependency(
site.in_source_dir(path),
site.in_source_dir(layout.path)
)
if (layout = layouts[layout.data["layout"]])
break if used.include?(layout)
used << layout
end
end
_renderer.layouts = layouts
self.output = _renderer.place_in_layouts(output, payload, info)
ensure
@_renderer = nil # this will allow the modifications above to disappear
end
# Add any necessary layouts to this convertible document.
@ -254,32 +205,15 @@ module Jekyll
#
# Returns nothing.
def do_layout(payload, layouts)
Jekyll.logger.debug "Rendering:", self.relative_path
self.output = _renderer.tap do |renderer|
renderer.layouts = layouts
renderer.payload = payload
end.run
Jekyll.logger.debug "Pre-Render Hooks:", self.relative_path
Jekyll::Hooks.trigger hook_owner, :pre_render, self, payload
info = {
:filters => [Jekyll::Filters],
:registers => { :site => site, :page => payload["page"] }
}
# render and transform content (this becomes the final content of the object)
payload["highlighter_prefix"] = converters.first.highlighter_prefix
payload["highlighter_suffix"] = converters.first.highlighter_suffix
if render_with_liquid?
Jekyll.logger.debug "Rendering Liquid:", self.relative_path
self.content = render_liquid(content, payload, info, path)
end
Jekyll.logger.debug "Rendering Markup:", self.relative_path
self.content = transform
# output keeps track of what will finally be written
self.output = content
render_all_layouts(layouts, payload, info) if place_in_layout?
Jekyll.logger.debug "Post-Render Hooks:", self.relative_path
Jekyll::Hooks.trigger hook_owner, :post_render, self
ensure
@_renderer = nil # this will allow the modifications above to disappear
end
# Write the generated page file to the destination directory.
@ -306,5 +240,10 @@ module Jekyll
data[property]
end
end
private
def _renderer
@_renderer ||= Jekyll::Renderer.new(site, self)
end
end
end

View File

@ -51,19 +51,9 @@ module Jekyll
#
# Returns the merged data.
def merge_data!(other, source: "YAML front matter")
if other.key?("categories") && !other["categories"].nil?
if other["categories"].is_a?(String)
other["categories"] = other["categories"].split(" ").map(&:strip)
end
other["categories"] = (data["categories"] || []) | other["categories"]
end
merge_categories!(other)
Utils.deep_merge_hashes!(data, other)
if data.key?("date") && !data["date"].is_a?(Time)
data["date"] = Utils.parse_date(
data["date"].to_s,
"Document '#{relative_path}' does not have a valid date in the #{source}."
)
end
merge_date!(source)
data
end
@ -90,8 +80,7 @@ module Jekyll
# Returns a String path which represents the relative path
# from the site source to this document
def relative_path
@relative_path ||= Pathname.new(path)
.relative_path_from(Pathname.new(site.source)).to_s
@relative_path ||= Pathutil.new(path).relative_path_from(site.source).to_s
end
# The output extension of the document.
@ -264,20 +253,9 @@ module Jekyll
@data = SafeYAML.load_file(path)
else
begin
defaults = @site.frontmatter_defaults.all(
relative_path,
collection.label.to_sym
)
merge_data!(defaults, :source => "front matter defaults") unless defaults.empty?
self.content = File.read(path, Utils.merged_file_read_opts(site, opts))
if content =~ YAML_FRONT_MATTER_REGEXP
self.content = $POSTMATCH
data_file = SafeYAML.load(Regexp.last_match(1))
merge_data!(data_file, :source => "YAML front matter") if data_file
end
post_read
merge_defaults
read_content(opts)
read_post_data
rescue SyntaxError => e
Jekyll.logger.error "Error:", "YAML Exception reading #{path}: #{e.message}"
rescue => e
@ -287,56 +265,6 @@ module Jekyll
end
end
def post_read
if relative_path =~ DATE_FILENAME_MATCHER
date, slug, ext = Regexp.last_match.captures
if !data["date"] || data["date"].to_i == site.time.to_i
merge_data!({ "date" => date }, :source => "filename")
end
elsif relative_path =~ DATELESS_FILENAME_MATCHER
slug, ext = Regexp.last_match.captures
end
# Try to ensure the user gets a title.
data["title"] ||= Utils.titleize_slug(slug)
# Only overwrite slug & ext if they aren't specified.
data["slug"] ||= slug
data["ext"] ||= ext
populate_categories
populate_tags
generate_excerpt
end
# Add superdirectories of the special_dir to categories.
# In the case of es/_posts, 'es' is added as a category.
# In the case of _posts/es, 'es' is NOT added as a category.
#
# Returns nothing.
def categories_from_path(special_dir)
superdirs = relative_path.sub(%r!#{special_dir}(.*)!, "")
.split(File::SEPARATOR)
.reject do |c|
c.empty? || c.eql?(special_dir) || c.eql?(basename)
end
merge_data!({ "categories" => superdirs }, :source => "file path")
end
def populate_categories
merge_data!({
"categories" => (
Array(data["categories"]) +
Utils.pluralized_array_from_hash(data, "category", "categories")
).map(&:to_s).flatten.uniq
})
end
def populate_tags
merge_data!({
"tags" => Utils.pluralized_array_from_hash(data, "tag", "tags").flatten
})
end
# Create a Liquid-understandable version of this Document.
#
# Returns a Hash representing this Document's data.
@ -443,7 +371,116 @@ module Jekyll
end
end
private # :nodoc:
def respond_to_missing?(method, *)
data.key?(method.to_s) || super
end
private
def merge_categories!(other)
if other.key?("categories") && !other["categories"].nil?
if other["categories"].is_a?(String)
other["categories"] = other["categories"].split(%r!\s+!).map(&:strip)
end
other["categories"] = (data["categories"] || []) | other["categories"]
end
end
private
def merge_date!(source)
if data.key?("date") && !data["date"].is_a?(Time)
data["date"] = Utils.parse_date(
data["date"].to_s,
"Document '#{relative_path}' does not have a valid date in the #{source}."
)
end
end
private
def merge_defaults
defaults = @site.frontmatter_defaults.all(
relative_path,
collection.label.to_sym
)
merge_data!(defaults, :source => "front matter defaults") unless defaults.empty?
end
private
def read_content(opts)
self.content = File.read(path, Utils.merged_file_read_opts(site, opts))
if content =~ YAML_FRONT_MATTER_REGEXP
self.content = $POSTMATCH
data_file = SafeYAML.load(Regexp.last_match(1))
merge_data!(data_file, :source => "YAML front matter") if data_file
end
end
private
def read_post_data
populate_title
populate_categories
populate_tags
generate_excerpt
end
private
def populate_title
if relative_path =~ DATE_FILENAME_MATCHER
date, slug, ext = Regexp.last_match.captures
modify_date(date)
elsif relative_path =~ DATELESS_FILENAME_MATCHER
slug, ext = Regexp.last_match.captures
end
# Try to ensure the user gets a title.
data["title"] ||= Utils.titleize_slug(slug)
# Only overwrite slug & ext if they aren't specified.
data["slug"] ||= slug
data["ext"] ||= ext
end
private
def modify_date(date)
if !data["date"] || data["date"].to_i == site.time.to_i
merge_data!({ "date" => date }, :source => "filename")
end
end
# Add superdirectories of the special_dir to categories.
# In the case of es/_posts, 'es' is added as a category.
# In the case of _posts/es, 'es' is NOT added as a category.
#
# Returns nothing.
private
def categories_from_path(special_dir)
superdirs = relative_path.sub(%r!#{special_dir}(.*)!, "")
.split(File::SEPARATOR)
.reject do |c|
c.empty? || c == special_dir || c == basename
end
merge_data!({ "categories" => superdirs }, :source => "file path")
end
private
def populate_categories
merge_data!({
"categories" => (
Array(data["categories"]) + Utils.pluralized_array_from_hash(
data,
"category",
"categories"
)
).map(&:to_s).flatten.uniq
})
end
private
def populate_tags
merge_data!({
"tags" => Utils.pluralized_array_from_hash(data, "tag", "tags").flatten
})
end
private
def generate_excerpt
if generate_excerpt?
data["excerpt"] ||= Jekyll::Excerpt.new(self)

View File

@ -3,8 +3,11 @@ require "json"
require "date"
require "liquid"
require_all "jekyll/filters"
module Jekyll
module Filters
include URLFilters
# Convert a Markdown string into HTML output.
#
# input - The Markdown String to convert.

View File

@ -0,0 +1,38 @@
module Jekyll
module Filters
module URLFilters
# Produces an absolute URL based on site.url and site.baseurl.
#
# input - the URL to make absolute.
#
# Returns the absolute URL as a String.
def absolute_url(input)
return if input.nil?
site = @context.registers[:site]
return relative_url(input).to_s if site.config["url"].nil?
URI(site.config["url"] + relative_url(input)).to_s
end
# Produces a URL relative to the domain root based on site.baseurl.
#
# input - the URL to make relative to the domain root
#
# Returns a URL relative to the domain root as a String.
def relative_url(input)
return if input.nil?
site = @context.registers[:site]
return ensure_leading_slash(input.to_s) if site.config["baseurl"].nil?
URI(
ensure_leading_slash(site.config["baseurl"]) + ensure_leading_slash(input.to_s)
).to_s
end
private
def ensure_leading_slash(input)
return input if input.nil? || input.empty? || input.start_with?("/")
"/#{input}"
end
end
end
end

View File

@ -54,7 +54,7 @@ module Jekyll
# Ensure the priority is a Fixnum
def self.priority_value(priority)
return priority if priority.is_a?(Fixnum)
return priority if priority.is_a?(Integer)
PRIORITY_MAP[priority] || DEFAULT_PRIORITY
end

View File

@ -40,7 +40,11 @@ module Jekyll
@base = base
@dir = dir
@name = name
@path = site.in_source_dir(base, dir, name)
@path = if site.in_theme_dir(base) == base # we're in a theme
site.in_theme_dir(base, dir, name)
else
site.in_source_dir(base, dir, name)
end
process(name)
read_yaml(File.join(base, dir), name)

View File

@ -18,6 +18,7 @@ module Jekyll
sort_files!
@site.data = DataReader.new(site).read(site.config["data_dir"])
CollectionReader.new(site).read
ThemeAssetsReader.new(site).read
end
# Sorts posts, pages, and static files.

View File

@ -0,0 +1,47 @@
module Jekyll
class ThemeAssetsReader
attr_reader :site
def initialize(site)
@site = site
end
def read
return unless site.theme && site.theme.assets_path
Find.find(site.theme.assets_path) do |path|
next if File.directory?(path)
if File.symlink?(path)
Jekyll.logger.warn "Theme reader:", "Ignored symlinked asset: #{path}"
else
read_theme_asset(path)
end
end
end
private
def read_theme_asset(path)
base = site.theme.root
dir = File.dirname(path.sub("#{site.theme.root}/", ""))
name = File.basename(path)
if Utils.has_yaml_header?(path)
append_unless_exists site.pages,
Jekyll::Page.new(site, base, dir, name)
else
append_unless_exists site.static_files,
Jekyll::StaticFile.new(site, base, dir, name)
end
end
def append_unless_exists(haystack, new_item)
if haystack.any? { |file| file.relative_path == new_item.relative_path }
Jekyll.logger.debug "Theme:",
"Ignoring #{new_item.relative_path} in theme due to existing file " \
"with that path in site."
return
end
haystack << new_item
end
end
end

View File

@ -2,12 +2,32 @@
module Jekyll
class Renderer
attr_reader :document, :site, :payload
attr_reader :document, :site
attr_writer :layouts, :payload
def initialize(site, document, site_payload = nil)
@site = site
@document = document
@payload = site_payload || site.site_payload
@payload = site_payload
end
# Fetches the payload used in Liquid rendering.
# It can be written with #payload=(new_payload)
# Falls back to site.site_payload if no payload is set.
#
# Returns a Jekyll::Drops::UnifiedPayloadDrop
def payload
@payload ||= site.site_payload
end
# The list of layouts registered for this Renderer.
# It can be written with #layouts=(new_layouts)
# Falls back to site.layouts if no layouts are registered.
#
# Returns a Hash of String => Jekyll::Layout identified
# as basename without the extension name.
def layouts
@layouts || site.layouts
end
# Determine which converters to use based on this document's
@ -15,7 +35,7 @@ module Jekyll
#
# Returns an array of Converter instances.
def converters
@converters ||= site.converters.select { |c| c.matches(document.extname) }
@converters ||= site.converters.select { |c| c.matches(document.extname) }.sort
end
# Determine the extname the outputted file should have
@ -126,7 +146,7 @@ module Jekyll
#
# Returns true if the layout is invalid, false if otherwise
def invalid_layout?(layout)
!document.data["layout"].nil? && layout.nil?
!document.data["layout"].nil? && layout.nil? && !(document.is_a? Jekyll::Excerpt)
end
# Render layouts and place given content inside.
@ -137,7 +157,7 @@ module Jekyll
# Returns the content placed in the Liquid-rendered layouts
def place_in_layouts(content, payload, info)
output = content.dup
layout = site.layouts[document.data["layout"]]
layout = layouts[document.data["layout"]]
Jekyll.logger.warn(
"Build Warning:",
@ -167,7 +187,7 @@ module Jekyll
site.in_source_dir(layout.path)
) if document.write?
if (layout = site.layouts[layout.data["layout"]])
if (layout = layouts[layout.data["layout"]])
break if used.include?(layout)
used << layout
end

View File

@ -424,7 +424,16 @@ module Jekyll
private
def configure_theme
self.theme = nil
self.theme = Jekyll::Theme.new(config["theme"]) if config["theme"]
return if config["theme"].nil?
self.theme =
if config["theme"].is_a?(String)
Jekyll::Theme.new(config["theme"])
else
Jekyll.logger.warn "Theme:", "value of 'theme' in config should be " \
"String to use gem-based themes, but got #{config["theme"].class}"
nil
end
end
private

View File

@ -8,7 +8,7 @@ module Jekyll
# forms: name, name=value, or name="<quoted list>"
#
# <quoted list> is a space-separated list of numbers
SYNTAX = %r!^([a-zA-Z0-9.+#-]+)((\s+\w+(=(\w+|"([0-9]+\s)*[0-9]+"))?)*)$!
SYNTAX = %r!^([a-zA-Z0-9.+#_-]+)((\s+\w+(=(\w+|"([0-9]+\s)*[0-9]+"))?)*)$!
def initialize(tag_name, markup, tokens)
super

View File

@ -16,8 +16,10 @@ module Jekyll
def render(context)
site = context.registers[:site]
site.docs_to_write.each do |document|
return document.url if document.relative_path == @relative_path
site.each_site_file do |item|
return item.url if item.relative_path == @relative_path
# This takes care of the case for static files that have a leading /
return item.url if item.relative_path == "/#{@relative_path}"
end
raise ArgumentError, <<eos

View File

@ -18,15 +18,19 @@ module Jekyll
end
def includes_path
path_for :includes
path_for "_includes".freeze
end
def layouts_path
path_for :layouts
path_for "_layouts".freeze
end
def sass_path
path_for :sass
path_for "_sass".freeze
end
def assets_path
path_for "assets".freeze
end
def configure_sass
@ -43,7 +47,7 @@ module Jekyll
end
def realpath_for(folder)
File.realpath(Jekyll.sanitized_path(root, "_#{folder}"))
File.realpath(Jekyll.sanitized_path(root, folder.to_s))
rescue Errno::ENOENT, Errno::EACCES, Errno::ELOOP
nil
end

View File

@ -1,6 +1,6 @@
class Jekyll::ThemeBuilder
SCAFFOLD_DIRECTORIES = %w(
_layouts _includes _sass
assets _layouts _includes _sass
).freeze
attr_reader :name, :path, :code_of_conduct

View File

@ -6,10 +6,11 @@ module Jekyll
autoload :Ansi, "jekyll/utils/ansi"
# Constants for use in #slugify
SLUGIFY_MODES = %w(raw default pretty).freeze
SLUGIFY_MODES = %w(raw default pretty ascii).freeze
SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
SLUGIFY_DEFAULT_REGEXP = Regexp.new("[^[:alnum:]]+").freeze
SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze
SLUGIFY_ASCII_REGEXP = Regexp.new("[^[A-Za-z0-9]]+").freeze
# Takes an indented string and removes the preceding spaces on each line
@ -160,6 +161,9 @@ module Jekyll
# When mode is "pretty", some non-alphabetic characters (._~!$&'()+,;=@)
# are not replaced with hyphen.
#
# When mode is "ascii", some everything else except ASCII characters
# a-z (lowercase), A-Z (uppercase) and 0-9 (numbers) are not replaced with hyphen.
#
# If cased is true, all uppercase letters in the result string are
# replaced with their lowercase counterparts.
#
@ -173,6 +177,9 @@ module Jekyll
# slugify("The _config.yml file", "pretty", true)
# # => "The-_config.yml file"
#
# slugify("The _config.yml file", "ascii")
# # => "the-config.yml-file"
#
# Returns the slugified string.
def slugify(string, mode: nil, cased: false)
mode ||= "default"
@ -193,6 +200,11 @@ module Jekyll
# "._~!$&'()+,;=@" is human readable (not URI-escaped) in URL
# and is allowed in both extN and NTFS.
SLUGIFY_PRETTY_REGEXP
when "ascii"
# For web servers not being able to handle Unicode, the safe
# method is to ditch anything else but latin letters and numeric
# digits.
SLUGIFY_ASCII_REGEXP
end
# Strip according to the mode

View File

@ -13,18 +13,55 @@ module Jekyll
end
end
# --
# Allows you to detect "real" Windows, or what we would consider
# "real" Windows. That is, that we can pass the basic test and the
# /proc/version returns nothing to us.
# --
def really_windows?
RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i && \
!proc_version
end
#
def windows?
RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i || \
proc_version =~ %r!microsoft!i
end
#
def linux?
RbConfig::CONFIG["host_os"] =~ %r!linux! && \
proc_version !~ %r!microsoft!i
end
# Provides windows?, linux?, osx?, unix? so that we can detect
# platforms. This is mostly useful for `jekyll doctor` and for testing
# where we kick off certain tests based on the platform.
{ :windows? => %r!mswin|mingw|cygwin!, :linux? => %r!linux!, \
:osx? => %r!darwin|mac os!, :unix? => %r!solaris|bsd! }.each do |k, v|
{ :osx? => %r!darwin|mac os!, :unix? => %r!solaris|bsd! }.each do |k, v|
define_method k do
!!(
RbConfig::CONFIG["host_os"] =~ v
)
end
end
#
private
def proc_version
@cached_proc_version ||= begin
Pathutil.new(
"/proc/version"
).read
rescue Errno::ENOENT
nil
end
end
end
end
end

View File

@ -20,7 +20,7 @@ description: > # this means to ignore newlines until "baseurl:"
line in _config.yml. It will appear in your document head meta (for
Google search results) and in your feed.xml site description.
baseurl: "" # the subpath of your site, e.g. /blog
url: "http://example.com" # the base hostname & protocol for your site
url: "" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: jekyllrb
github_username: jekyll
@ -29,3 +29,6 @@ markdown: kramdown
theme: minima
gems:
- jekyll-feed
exclude:
- Gemfile
- Gemfile.lock

View File

@ -1,39 +0,0 @@
---
# Only the main Sass file needs front matter (the dashes are enough)
---
@charset "utf-8";
// Our variables
$base-font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
$base-font-size: 16px;
$base-font-weight: 400;
$small-font-size: $base-font-size * 0.875;
$base-line-height: 1.5;
$spacing-unit: 30px;
$text-color: #111;
$background-color: #fdfdfd;
$brand-color: #2a7ae2;
$grey-color: #828282;
$grey-color-light: lighten($grey-color, 40%);
$grey-color-dark: darken($grey-color, 25%);
// Width of the content area
$content-width: 800px;
$on-palm: 600px;
$on-laptop: 800px;
// Minima also includes a mixin for defining media queries.
// Use media queries like this:
// @include media-query($on-palm) {
// .wrapper {
// padding-right: $spacing-unit / 2;
// padding-left: $spacing-unit / 2;
// }
// }
// Import partials from the `minima` theme.
@import "minima";

View File

@ -12,7 +12,7 @@ Add this line to your Jekyll site's Gemfile:
gem <%= theme_name.inspect %>
```
And add this line to your Jekyll site:
And add this line to your Jekyll site's `_config.yml`:
```yaml
theme: <%= theme_name %>

View File

@ -1,3 +1,4 @@
*.gem
.bundle
.sass-cache
_site

View File

@ -7,14 +7,12 @@ echo "$0: setting up tmp directory"
mkdir -p ./tmp
rm -Rf ./tmp/default-site
workdir=$(pwd)
echo "$0: creating new default site"
bundle exec exe/jekyll new tmp/default-site
bundle exec jekyll new tmp/default-site
pushd tmp/default-site
echo "$0: respecifying the jekyll install location"
ruby -e "contents = File.read('Gemfile'); File.write('Gemfile', contents.sub(/gem \"jekyll\".*\\n/, 'gem \"jekyll\", path: \"$workdir\"'))"
ruby -e "contents = File.read('Gemfile'); File.write('Gemfile', contents.sub(/gem \"jekyll\".*\\n/, 'gem \"jekyll\", path: \"../../\"'))"
echo "$0: installing default site dependencies"
BUNDLE_GEMFILE=Gemfile bundle install
echo "$0: building the default site"

View File

@ -10,7 +10,7 @@ For information about contributing, see the [Contributing page](http://jekyllrb.
You can preview your contributions before opening a pull request by running from within the directory:
1. `bundle install`
1. `bundle install --without test test_legacy benchmark`
2. `bundle exec rake site:preview`
It's just a jekyll site, afterall! :wink:

View File

@ -32,3 +32,7 @@ gems:
- jekyll-seo-tag
- jekyll-avatar
- jekyll-mentions
exclude:
- README.md
- .gitignore

View File

@ -9,14 +9,14 @@ a Ruby gem. In order to use them, you must first create a file with the
proper extension name (one of `.sass`, `.scss`, or `.coffee`) and ***start the
file with two lines of triple dashes***, like this:
{% highlight sass %}
```sass
---
---
// start content
.my-definition
font-size: 1.2em
{% endhighlight %}
```
Jekyll treats these files the same as a regular page, in that the output file
will be placed in the same directory that it came from. For instance, if you
@ -46,10 +46,10 @@ If you are using Sass `@import` statements, you'll need to ensure that your
`sass_dir` is set to the base directory that contains your Sass files. You
can do that thusly:
{% highlight yaml %}
```yaml
sass:
sass_dir: _sass
{% endhighlight %}
```
The Sass converter will default the `sass_dir` configuration option to
`_sass`.
@ -72,10 +72,10 @@ The Sass converter will default the `sass_dir` configuration option to
You may also specify the output style with the `style` option in your
`_config.yml` file:
{% highlight yaml %}
```yaml
sass:
style: compressed
{% endhighlight %}
```
These are passed to Sass, so any output style options Sass supports are valid
here, too.
@ -88,7 +88,7 @@ To enable Coffeescript in Jekyll 3.0 and up you must
* Install the `jekyll-coffeescript` gem
* Ensure that your `_config.yml` is up-to-date and includes the following:
{% highlight yaml %}
```yaml
gems:
- jekyll-coffeescript
{% endhighlight %}
```

View File

@ -17,29 +17,29 @@ namespace.
Add the following to your site's `_config.yml` file, replacing `my_collection`
with the name of your collection:
{% highlight yaml %}
```yaml
collections:
- my_collection
{% endhighlight %}
```
You can optionally specify metadata for your collection in the configuration:
{% highlight yaml %}
```yaml
collections:
my_collection:
foo: bar
{% endhighlight %}
```
Default attributes can also be set for a collection:
{% highlight yaml %}
```yaml
defaults:
- scope:
path: ""
type: my_collection
values:
layout: page
{% endhighlight %}
```
### Step 2: Add your content
@ -62,11 +62,11 @@ If you'd like Jekyll to create a public-facing, rendered version of each
document in your collection, set the `output` key to `true` in your collection
metadata in your `_config.yml`:
{% highlight yaml %}
```yaml
collections:
my_collection:
output: true
{% endhighlight %}
```
This will produce a file for each document in the collection.
For example, if you have `_my_collection/some_subdir/some_doc.md`,
@ -76,12 +76,12 @@ choice and written out to `<dest>/my_collection/some_subdir/some_doc.html`.
As for posts with [Permalinks](../permalinks/), the document
URL can be customized by setting `permalink` metadata for the collection:
{% highlight yaml %}
```yaml
collections:
my_collection:
output: true
permalink: /awesome/:path/
{% endhighlight %}
```
For example, if you have `_my_collection/some_subdir/some_doc.md`, it will be
written out to `<dest>/awesome/some_subdir/some_doc/index.html`.
@ -339,7 +339,7 @@ one might have front matter in an individual file structured as follows (which
must use a supported markup format, and cannot be saved with a `.yaml`
extension):
{% highlight yaml %}
```yaml
title: "Josquin: Missa De beata virgine and Missa Ave maris stella"
artist: "The Tallis Scholars"
director: "Peter Phillips"
@ -357,11 +357,11 @@ works:
duration: "7:47"
- title: "Agnus Dei I, II & III"
duration: "6:49"
{% endhighlight %}
```
Every album in the collection could be listed on a single page with a template:
{% highlight html %}
```html
{% raw %}
{% for album in site.albums %}
<h2>{{ album.title }}</h2>
@ -377,4 +377,4 @@ Every album in the collection could be listed on a single page with a template:
{% endfor %}
{% endfor %}
{% endraw %}
{% endhighlight %}
```

View File

@ -284,6 +284,18 @@ class="flag">flags</code> (specified on the command-line) that control them.
<p><code class="flag">-I, --incremental</code></p>
</td>
</tr>
<tr class="setting">
<td>
<p class="name"><strong>Liquid profiler</strong></p>
<p class="description">
Generate a Liquid rendering profile to help you identify performance bottlenecks.
</p>
</td>
<td class="align-center">
<p><code class="option">profile: BOOL</code></p>
<p><code class="flag">--profile</code></p>
</td>
</tr>
</tbody>
</table>
</div>
@ -387,13 +399,13 @@ before your site is served.
You can provide custom headers for your site by adding them to `_config.yml`
{% highlight yaml %}
```yaml
# File: _config.yml
webrick:
headers:
My-Header: My-Value
My-Other-Header: My-Other-Value
{% endhighlight %}
```
### Defaults
@ -408,19 +420,19 @@ In the build (or serve) arguments, you can specify a Jekyll environment and valu
For example, suppose you set this conditional statement in your code:
{% highlight liquid %}
```liquid
{% raw %}
{% if jekyll.environment == "production" %}
{% include disqus.html %}
{% endif %}
{% endraw %}
{% endhighlight %}
```
When you build your Jekyll site, the content inside the `if` statement won't be run unless you also specify a `production` environment in the build command, like this:
{% highlight sh %}
```sh
JEKYLL_ENV=production jekyll build
{% endhighlight %}
```
Specifying an environment value allows you to make certain content available only within specific environments.
@ -442,14 +454,14 @@ The `defaults` key holds an array of scope/values pairs that define what default
Let's say that you want to add a default layout to all pages and posts in your site. You would add this to your `_config.yml` file:
{% highlight yaml %}
```yaml
defaults:
-
scope:
path: "" # an empty string here means all files in the project
values:
layout: "default"
{% endhighlight %}
```
<div class="note info">
<h5>Please stop and rerun `jekyll serve` command.</h5>
@ -465,7 +477,7 @@ defaults:
Here, we are scoping the `values` to any file that exists in the path `scope`. Since the path is set as an empty string, it will apply to **all files** in your project. You probably don't want to set a layout on every file in your project - like css files, for example - so you can also specify a `type` value under the `scope` key.
{% highlight yaml %}
```yaml
defaults:
-
scope:
@ -473,14 +485,14 @@ defaults:
type: "posts" # previously `post` in Jekyll 2.2.
values:
layout: "default"
{% endhighlight %}
```
Now, this will only set the layout for files where the type is `posts`.
The different types that are available to you are `pages`, `posts`, `drafts` or any collection in your site. While `type` is optional, you must specify a value for `path` when creating a `scope/values` pair.
As mentioned earlier, you can set multiple scope/values pairs for `defaults`.
{% highlight yaml %}
```yaml
defaults:
-
scope:
@ -495,11 +507,11 @@ defaults:
values:
layout: "project" # overrides previous default layout
author: "Mr. Hyde"
{% endhighlight %}
```
With these defaults, all posts would use the `my-site` layout. Any html files that exist in the `projects/` folder will use the `project` layout, if it exists. Those files will also have the `page.author` [liquid variable](../variables/) set to `Mr. Hyde`.
{% highlight yaml %}
```yaml
collections:
- my_collection:
output: true
@ -511,7 +523,7 @@ defaults:
type: "my_collection" # a collection in your site, in plural form
values:
layout: "default"
{% endhighlight %}
```
In this example, the `layout` is set to `default` inside the
[collection](../collections/) with the name `my_collection`.
@ -524,7 +536,7 @@ You can see that in the second to last example above. First, we set the default
Finally, if you set defaults in the site configuration by adding a `defaults` section to your `_config.yml` file, you can override those settings in a post or page file. All you need to do is specify the settings in the post or page front matter. For example:
{% highlight yaml %}
```yaml
# In _config.yml
...
defaults:
@ -537,16 +549,16 @@ defaults:
author: "Mr. Hyde"
category: "project"
...
{% endhighlight %}
```
{% highlight yaml %}
```yaml
# In projects/foo_project.md
---
author: "John Smith"
layout: "foobar"
---
The post text goes here...
{% endhighlight %}
```
The `projects/foo_project.md` would have the `layout` set to `foobar` instead
of `project` and the `author` set to `John Smith` instead of `Mr. Hyde` when
@ -567,7 +579,7 @@ file or on the command-line.
</p>
</div>
{% highlight yaml %}
```yaml
# Where things are
source: .
destination: ./_site
@ -582,7 +594,7 @@ collections:
# Handling Reading
safe: false
include: [".htaccess"]
exclude: []
exclude: ["vendor"]
keep_files: [".git", ".svn"]
encoding: "utf-8"
markdown_ext: "markdown,mkdown,mkdn,mkd,md"
@ -639,7 +651,7 @@ kramdown:
input: GFM
hard_wrap: false
footnote_nr: 1
{% endhighlight %}
```
## Liquid Options
@ -703,7 +715,7 @@ extensions are:
If you're interested in creating a custom markdown processor, you're in luck! Create a new class in the `Jekyll::Converters::Markdown` namespace:
{% highlight ruby %}
```ruby
class Jekyll::Converters::Markdown::MyCustomProcessor
def initialize(config)
require 'funky_markdown'
@ -718,14 +730,14 @@ class Jekyll::Converters::Markdown::MyCustomProcessor
::FunkyMarkdown.new(content).convert
end
end
{% endhighlight %}
```
Once you've created your class and have it properly set up either as a plugin
in the `_plugins` folder or as a gem, specify it in your `_config.yml`:
{% highlight yaml %}
```yaml
markdown: MyCustomProcessor
{% endhighlight %}
```
## Incremental Regeneration
<div class="note warning">

View File

@ -19,7 +19,7 @@ Enabling Travis builds for your GitHub repository is pretty simple:
1. Go to your profile on travis-ci.org: https://travis-ci.org/profile/username
2. Find the repository for which you're interested in enabling builds.
3. Click the slider on the right so it says "ON" and is a dark grey.
4. Optionally configure the build by clicking on the wrench icon. Further
4. Optionally configure the build by clicking on the gear icon. Further
configuration happens in your `.travis.yml` file. More details on that
below.
@ -38,13 +38,13 @@ Save the commands you want to run and succeed in a file: `./script/cibuild`
### The HTML Proofer Executable
{% highlight shell %}
```sh
#!/usr/bin/env bash
set -e # halt script on error
bundle exec jekyll build
bundle exec htmlproofer ./_site
{% endhighlight %}
```
Some options can be specified via command-line switches. Check out the
`html-proofer` README for more information about these switches, or run
@ -52,20 +52,20 @@ Some options can be specified via command-line switches. Check out the
For example to avoid testing external sites, use this command:
{% highlight shell %}
```sh
$ bundle exec htmlproofer ./_site --disable-external
{% endhighlight %}
```
### The HTML Proofer Library
You can also invoke `html-proofer` in Ruby scripts (e.g. in a Rakefile):
{% highlight ruby %}
```ruby
#!/usr/bin/env ruby
require 'html-proofer'
HTMLProofer.check_directory("./_site").run
{% endhighlight %}
```
Options are given as a second argument to `.new`, and are encoded in a
symbol-keyed Ruby Hash. For more information about the configuration options,
@ -82,16 +82,16 @@ an explanation of each line.
**Note:** You will need a Gemfile as well, [Travis will automatically install](https://docs.travis-ci.com/user/languages/ruby/#Dependency-Management) the dependencies based on the referenced gems:
{% highlight ruby %}
```ruby
source "https://rubygems.org"
gem "jekyll"
gem "html-proofer"
{% endhighlight %}
```
Your `.travis.yml` file should look like this:
{% highlight yaml %}
```yaml
language: ruby
rvm:
- 2.1
@ -114,39 +114,39 @@ env:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer
sudo: false # route your build to the container-based infrastructure for a faster build
{% endhighlight %}
```
Ok, now for an explanation of each line:
{% highlight yaml %}
```yaml
language: ruby
{% endhighlight %}
```
This line tells Travis to use a Ruby build container. It gives your script
access to Bundler, RubyGems, and a Ruby runtime.
{% highlight yaml %}
```yaml
rvm:
- 2.1
{% endhighlight %}
```
RVM is a popular Ruby Version Manager (like rbenv, chruby, etc). This
directive tells Travis the Ruby version to use when running your test
script.
{% highlight yaml %}
```yaml
before_script:
- chmod +x ./script/cibuild
{% endhighlight %}
```
The build script file needs to have the *executable* attribute set or
Travis will fail with a permission denied error. You can also run this
locally and commit the permissions directly, thus rendering this step
irrelevant.
{% highlight yaml %}
```yaml
script: ./script/cibuild
{% endhighlight %}
```
Travis allows you to run any arbitrary shell script to test your site. One
convention is to put all scripts for your project in the `script`
@ -154,20 +154,20 @@ directory, and to call your test script `cibuild`. This line is completely
customizable. If your script won't change much, you can write your test
incantation here directly:
{% highlight yaml %}
```yaml
install: gem install jekyll html-proofer
script: jekyll build && htmlproofer ./_site
{% endhighlight %}
```
The `script` directive can be absolutely any valid shell command.
{% highlight yaml %}
```yaml
# branch whitelist, only for GitHub Pages
branches:
only:
- gh-pages # test the gh-pages branch
- /pages-(.*)/ # test every branch which starts with "pages-"
{% endhighlight %}
```
You want to ensure the Travis builds for your site are being run only on
the branch or branches which contain your site. One means of ensuring this
@ -181,11 +181,11 @@ prefixed, exemplified above with the `/pages-(.*)/` regular expression.
The `branches` directive is completely optional. Travis will build from every
push to any branch of your repo if leave it out.
{% highlight yaml %}
```yaml
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer
{% endhighlight %}
```
Using `html-proofer`? You'll want this environment variable. Nokogiri, used
to parse HTML files in your compiled site, comes bundled with libraries
@ -200,9 +200,9 @@ environment variable `NOKOGIRI_USE_SYSTEM_LIBRARIES` to `true`.
servers, which Jekyll will mistakenly read and explode on.</p>
</div>
{% highlight yaml %}
```yaml
exclude: [vendor]
{% endhighlight %}
```
By default you should supply the `sudo: false` command to Travis. This command
explicitly tells Travis to run your build on Travis's [container-based
@ -210,9 +210,9 @@ explicitly tells Travis to run your build on Travis's [container-based
speed up your build. If you have any trouble with your build, or if your build
does need `sudo` access, modify the line to `sudo: required`.
{% highlight yaml %}
```yaml
sudo: false
{% endhighlight %}
```
### Troubleshooting

View File

@ -32,7 +32,7 @@ of code in your Jekyll templates:
In `_data/members.yml`:
{% highlight yaml %}
```yaml
- name: Eric Mill
github: konklone
@ -41,23 +41,23 @@ In `_data/members.yml`:
- name: Liu Fengyun
github: liufengyun
{% endhighlight %}
```
Or `_data/members.csv`:
{% highlight text %}
```text
name,github
Eric Mill,konklone
Parker Moore,parkr
Liu Fengyun,liufengyun
{% endhighlight %}
```
This data can be accessed via `site.data.members` (notice that the filename
determines the variable name).
You can now render the list of members in a template:
{% highlight html %}
```html
{% raw %}
<ul>
{% for member in site.data.members %}
@ -69,7 +69,7 @@ You can now render the list of members in a template:
{% endfor %}
</ul>
{% endraw %}
{% endhighlight %}
```
## Example: Organizations
@ -80,7 +80,7 @@ folder:
In `_data/orgs/jekyll.yml`:
{% highlight yaml %}
```yaml
username: jekyll
name: Jekyll
members:
@ -89,22 +89,22 @@ members:
- name: Parker Moore
github: parkr
{% endhighlight %}
```
In `_data/orgs/doeorg.yml`:
{% highlight yaml %}
```yaml
username: doeorg
name: Doe Org
members:
- name: John Doe
github: jdoe
{% endhighlight %}
```
The organizations can then be accessed via `site.data.orgs`, followed by the
file name:
{% highlight html %}
```html
{% raw %}
<ul>
{% for org_hash in site.data.orgs %}
@ -118,22 +118,22 @@ file name:
{% endfor %}
</ul>
{% endraw %}
{% endhighlight %}
```
## Example: Accessing a specific author
Pages and posts can also access a specific data item. The example below shows how to access a specific item:
`_data/people.yml`:
{% highlight yaml %}
```yaml
dave:
name: David Smith
twitter: DavidSilvaSmith
{% endhighlight %}
```
The author can then be specified as a page variable in a post's frontmatter:
{% highlight html %}
```html
{% raw %}
---
title: sample post
@ -148,4 +148,4 @@ author: dave
</a>
{% endraw %}
{% endhighlight %}
```

View File

@ -35,19 +35,19 @@ this](http://web.archive.org/web/20091223025644/http://www.taknado.com/en/2009/0
To have a remote server handle the deploy for you every time you push changes using Git, you can create a user account which has all the public keys that are authorized to deploy in its `authorized_keys` file. With that in place, setting up the post-receive hook is done as follows:
{% highlight shell %}
```sh
laptop$ ssh deployer@example.com
server$ mkdir myrepo.git
server$ cd myrepo.git
server$ git --bare init
server$ cp hooks/post-receive.sample hooks/post-receive
server$ mkdir /var/www/myrepo
{% endhighlight %}
```
Next, add the following lines to hooks/post-receive and be sure Jekyll is
installed on the server:
{% highlight shell %}
```sh
GIT_REPO=$HOME/myrepo.git
TMP_GIT_CLONE=$HOME/tmp/myrepo
PUBLIC_WWW=/var/www/myrepo
@ -56,21 +56,21 @@ git clone $GIT_REPO $TMP_GIT_CLONE
jekyll build -s $TMP_GIT_CLONE -d $PUBLIC_WWW
rm -Rf $TMP_GIT_CLONE
exit
{% endhighlight %}
```
Finally, run the following command on any users laptop that needs to be able to
deploy using this hook:
{% highlight shell %}
```sh
laptops$ git remote add deploy deployer@example.com:~/myrepo.git
{% endhighlight %}
```
Deploying is now as easy as telling nginx or Apache to look at
`/var/www/myrepo` and running the following:
{% highlight shell %}
```sh
laptops$ git push deploy master
{% endhighlight %}
```
### Jekyll-hook
@ -98,12 +98,13 @@ Another way to deploy your Jekyll site is to use [Rake](https://github.com/ruby/
### scp
Once youve generated the `_site` directory, you can easily scp it using a
`tasks/deploy` shell script similar to this:
`tasks/deploy` shell script similar to [this deploy script][]. Youd obviously
need to change the values to reflect your sites details. There is even [a
matching TextMate command][] that will help you run this script.
#!/bin/bash
scp -r _site/* user@server:/home/user/public_html
[this deploy script here]: https://github.com/henrik/henrik.nyh.se/blob/master/script/deploy
[a matching TextMate command]: https://gist.github.com/henrik/214959
### rsync
@ -128,9 +129,9 @@ is to put the restriction to certificate-based authorization in
`~/.ssh/authorized_keys`. Then, launch `rrsync` and supply
it with the folder it shall have read-write access to:
{% highlight shell %}
```sh
command="$HOME/bin/rrsync <folder>",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ssh-rsa <cert>
{% endhighlight %}
```
`<folder>` is the path to your site. E.g., `~/public_html/you.org/blog-html/`.
@ -138,11 +139,11 @@ command="$HOME/bin/rrsync <folder>",no-agent-forwarding,no-port-forwarding,no-pt
Add the `deploy` script to the site source folder:
{% highlight shell %}
```sh
#!/bin/sh
rsync -crvz --rsh='ssh -p2222' --delete-after --delete-excluded <folder> <user>@<site>:
{% endhighlight %}
```
Command line parameters are:
@ -154,9 +155,9 @@ your host uses a different port than the default (e.g, HostGator)
Using this setup, you might run the following command:
{% highlight shell %}
```sh
rsync -crvz --rsh='ssh -p2222' --delete-after --delete-excluded _site/ hostuser@example.org:
{% endhighlight %}
```
Don't forget the column `:` after server name!
@ -168,10 +169,10 @@ copy it to the output folder. This behavior can be changed in `_config.yml`.
Just add the following line:
{% highlight yaml %}
```yaml
# Do not copy these files to the output directory
exclude: ["deploy"]
{% endhighlight %}
```
Alternatively, you can use an `rsync-exclude.txt` file to control which files will be transferred to your server.
@ -204,7 +205,7 @@ low-volume blogs as you only pay for what you use.
## OpenShift
If you'd like to deploy your site to an OpenShift gear, there's [a cartridge
for that](https://github.com/openshift-cartridges/openshift-jekyll-cartridge).
for that](https://github.com/openshift-quickstart/jekyll-openshift).
<div class="note">
<h5>ProTip™: Use GitHub Pages for zero-hassle Jekyll hosting</h5>

View File

@ -9,10 +9,10 @@ don't want to publish yet. To get up and running with drafts, create a
`_drafts` folder in your site's root (as described in the [site structure](/docs/structure/) section) and create your
first draft:
{% highlight text %}
```text
|-- _drafts/
| |-- a-draft-post.md
{% endhighlight %}
```
To preview your site with drafts, simply run `jekyll serve` or `jekyll build`
with the `--drafts` switch. Each will be assigned the value modification time

View File

@ -11,9 +11,9 @@ may want to install, depending on how you plan to use Jekyll.
Kramdown comes with optional support for LaTeX to PNG rendering via [MathJax](https://www.mathjax.org) within math blocks. See the Kramdown documentation on [math blocks](http://kramdown.gettalong.org/syntax.html#math-blocks) and [math support](http://kramdown.gettalong.org/converter/html.html#math-support) for more details. MathJax requires you to include JavaScript or CSS to render the LaTeX, e.g.
{% highlight html %}
```html
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
{% endhighlight %}
```
For more information about getting started, check out [this excellent blog post](http://gastonsanchez.com/opinion/2014/02/16/Mathjax-with-jekyll/).

View File

@ -10,12 +10,12 @@ Jekyll as a special file. The front matter must be the first thing in the file
and must take the form of valid YAML set between triple-dashed lines. Here is a
basic example:
{% highlight yaml %}
```yaml
---
layout: post
title: Blogging Like a Hacker
---
{% endhighlight %}
```
Between these triple-dashed lines, you can set predefined variables (see below
for a reference) or even create custom ones of your own. These variables will
@ -108,7 +108,7 @@ data that is sent to the Liquid templating engine during the conversion. For
instance, if you set a title, you can use that in your layout to set the page
title:
{% highlight html %}
```html
<!DOCTYPE HTML>
<html>
<head>
@ -116,7 +116,7 @@ title:
</head>
<body>
...
{% endhighlight %}
```
## Predefined Variables for Posts

View File

@ -22,14 +22,14 @@ branch to GitHub. However, the subdirectory-like URL structure GitHub uses for
Project Pages complicates the proper resolution of URLs. In order to assure your
site builds properly, use `site.github.url` in your URL's.
{% highlight html %}
```html
{% raw %}
<!-- Useful for styles with static names... -->
<link href="{{ site.github.url }}/path/to/css.css" rel="stylesheet">
<!-- and for documents/pages whose URL's can change... -->
<a href="{{ page.url | prepend: site.github.url }}">{{ page.title }}</a>
{% endraw %}
{% endhighlight %}
```
This way you can preview your site locally from the site root on localhost,
but when GitHub generates your pages from the gh-pages branch all the URLs
@ -54,7 +54,7 @@ few minor details.
currently-deployed version of the gem in your project, add the
following to your <code>Gemfile</code>:
{% highlight ruby %}
```ruby
source 'https://rubygems.org'
require 'json'
@ -62,18 +62,18 @@ require 'open-uri'
versions = JSON.parse(open('https://pages.github.com/versions.json').read)
gem 'github-pages', versions['github-pages']
{% endhighlight %}
```
This will ensure that when you run <code>bundle install</code>, you
have the correct version of the <code>github-pages</code> gem.
If that fails, simplify it:
{% highlight ruby %}
```ruby
source 'https://rubygems.org'
gem 'github-pages'
{% endhighlight %}
```
And be sure to run <code>bundle update</code> often.

View File

@ -7,7 +7,7 @@ permalink: /docs/installation/
Getting Jekyll installed and ready-to-go should only take a few minutes.
If it ever becomes a pain, please [file an issue]({{ site.repository }}/issues/new)
(or submit a pull request) describing the issue you
encountered and how we might make the process easier
encountered and how we might make the process easier.
### Requirements
@ -37,9 +37,9 @@ The best way to install Jekyll is via
[RubyGems](http://rubygems.org/pages/download). At the terminal prompt,
simply run the following command to install Jekyll:
{% highlight shell %}
```sh
$ gem install jekyll
{% endhighlight %}
```
All of Jekylls gem dependencies are automatically installed by the above
command, so you wont have to worry about them at all. If you have problems
@ -62,28 +62,28 @@ community can improve the experience for everyone.
In order to install a pre-release, make sure you have all the requirements
installed properly and run:
{% highlight shell %}
```sh
gem install jekyll --pre
{% endhighlight %}
```
This will install the latest pre-release. If you want a particular pre-release,
use the `-v` switch to indicate the version you'd like to install:
{% highlight shell %}
```sh
gem install jekyll -v '2.0.0.alpha.1'
{% endhighlight %}
```
If you'd like to install a development version of Jekyll, the process is a bit
more involved. This gives you the advantage of having the latest and greatest,
but may be unstable.
{% highlight shell %}
```sh
$ git clone git://github.com/jekyll/jekyll.git
$ cd jekyll
$ script/bootstrap
$ bundle exec rake build
$ ls pkg/*.gem | head -n 1 | xargs gem install -l
{% endhighlight %}
```
## Optional Extras

View File

@ -46,7 +46,7 @@ directory with a suitable name for the page you want to create. For a site with
a homepage, an about page, and a contact page, heres what the root directory
and associated URLs might look like:
{% highlight shell %}
```sh
.
|-- _config.yml
|-- _includes/
@ -57,7 +57,7 @@ and associated URLs might look like:
|-- index.html # => http://example.com/
|-- other.md # => http://example.com/other.html
└── contact.html # => http://example.com/contact.html
{% endhighlight %}
```
### Named folders containing index HTML files
@ -69,7 +69,7 @@ the page URL ends up being the folder name, and the web server will serve up
the respective `index.html` file. Here's an example of what this structure
might look like:
{% highlight shell %}
```sh
.
├── _config.yml
├── _includes/
@ -83,7 +83,7 @@ might look like:
|── other/
| └── index.md # => http://example.com/other/
└── index.html # => http://example.com/
{% endhighlight %}
```
This approach may not suit everyone, but for people who like clean URLs its
simple and it works. In the end, the decision is yours!

View File

@ -28,18 +28,18 @@ your `_config.yml` under `gems`. For Jekyll 2, this is standard.
To enable pagination for your blog, add a line to the `_config.yml` file that
specifies how many items should be displayed per page:
{% highlight yaml %}
```yaml
paginate: 5
{% endhighlight %}
```
The number should be the maximum number of Posts youd like to be displayed
per-page in the generated site.
You may also specify the destination of the pagination pages:
{% highlight yaml %}
```yaml
paginate_path: "/blog/page:num/"
{% endhighlight %}
```
This will read in `blog/index.html`, send it each pagination page in Liquid as
`paginator` and write the output to `blog/page:num/`, where `:num` is the
@ -146,7 +146,7 @@ the `paginator` variable that will now be available to you. Youll probably
want to do this in one of the main pages of your site. Heres one example of a
simple way of rendering paginated Posts in a HTML file:
{% highlight html %}
```html
{% raw %}
---
layout: default
@ -179,7 +179,7 @@ title: My Blog
{% endif %}
</div>
{% endraw %}
{% endhighlight %}
```
<div class="note warning">
<h5>Beware the page one edge-case</h5>
@ -193,7 +193,7 @@ title: My Blog
The following HTML snippet should handle page one, and render a list of each
page with links to all but the current page.
{% highlight html %}
```html
{% raw %}
{% if paginator.total_pages > 1 %}
<div class="pagination">
@ -221,4 +221,4 @@ page with links to all but the current page.
</div>
{% endif %}
{% endraw %}
{% endhighlight %}
```

View File

@ -93,7 +93,7 @@ For instance, a generator can inject values computed at build time for template
variables. In the following example the template `reading.html` has two
variables `ongoing` and `done` that we fill in the generator:
{% highlight ruby %}
```ruby
module Reading
class Generator < Jekyll::Generator
def generate(site)
@ -105,11 +105,11 @@ module Reading
end
end
end
{% endhighlight %}
```
This is a more complex generator that generates new pages:
{% highlight ruby %}
```ruby
module Jekyll
class CategoryPage < Page
@ -142,7 +142,7 @@ module Jekyll
end
end
{% endhighlight %}
```
In this example, our generator will create a series of files under the
`categories` directory for each category, listing the posts in each category
@ -189,7 +189,7 @@ languages are implemented using this method.
Below is a converter that will take all posts ending in `.upcase` and process
them using the `UpcaseConverter`:
{% highlight ruby %}
```ruby
module Jekyll
class UpcaseConverter < Converter
safe true
@ -208,7 +208,7 @@ module Jekyll
end
end
end
{% endhighlight %}
```
Converters should implement at a minimum 3 methods:
@ -266,16 +266,16 @@ As of version 2.5.0, Jekyll can be extended with plugins which provide
subcommands for the `jekyll` executable. This is possible by including the
relevant plugins in a `Gemfile` group called `:jekyll_plugins`:
{% highlight ruby %}
```ruby
group :jekyll_plugins do
gem "my_fancy_jekyll_plugin"
end
{% endhighlight %}
```
Each `Command` must be a subclass of the `Jekyll::Command` class and must
contain one class method: `init_with_program`. An example:
{% highlight ruby %}
```ruby
class MyNewCommand < Jekyll::Command
class << self
def init_with_program(prog)
@ -292,7 +292,7 @@ class MyNewCommand < Jekyll::Command
end
end
end
{% endhighlight %}
```
Commands should implement this single class method:
@ -328,7 +328,7 @@ hooking into the tagging system. Built-in examples added by Jekyll include the
`highlight` and `include` tags. Below is an example of a custom liquid tag that
will output the time the page was rendered:
{% highlight ruby %}
```ruby
module Jekyll
class RenderTimeTag < Liquid::Tag
@ -344,7 +344,7 @@ module Jekyll
end
Liquid::Template.register_tag('render_time', Jekyll::RenderTimeTag)
{% endhighlight %}
```
At a minimum, liquid tags must implement:
@ -372,24 +372,24 @@ At a minimum, liquid tags must implement:
You must also register the custom tag with the Liquid template engine as
follows:
{% highlight ruby %}
```ruby
Liquid::Template.register_tag('render_time', Jekyll::RenderTimeTag)
{% endhighlight %}
```
In the example above, we can place the following tag anywhere in one of our
pages:
{% highlight ruby %}
```ruby
{% raw %}
<p>{% render_time page rendered at: %}</p>
{% endraw %}
{% endhighlight %}
```
And we would get something like this on the page:
{% highlight html %}
```html
<p>page rendered at: Tue June 22 23:38:47 0500 2010</p>
{% endhighlight %}
```
### Liquid filters
@ -398,7 +398,7 @@ add tags above. Filters are simply modules that export their methods to liquid.
All methods will have to take at least one parameter which represents the input
of the filter. The return value will be the output of the filter.
{% highlight ruby %}
```ruby
module Jekyll
module AssetFilter
def asset_url(input)
@ -408,7 +408,7 @@ module Jekyll
end
Liquid::Template.register_filter(Jekyll::AssetFilter)
{% endhighlight %}
```
<div class="note">
<h5>ProTip™: Access the site object using Liquid</h5>
@ -469,7 +469,7 @@ There are two flags to be aware of when writing a plugin:
To use one of the example plugins above as an illustration, here is how youd
specify these two flags:
{% highlight ruby %}
```ruby
module Jekyll
class UpcaseConverter < Converter
safe true
@ -477,7 +477,7 @@ module Jekyll
...
end
end
{% endhighlight %}
```
## Hooks
@ -491,18 +491,20 @@ call whenever the hook is triggered. For example, if you want to execute some
custom functionality every time Jekyll renders a post, you could register a
hook like this:
{% highlight ruby %}
```ruby
Jekyll::Hooks.register :posts, :post_render do |post|
# code to call after Jekyll renders a post
end
{% endhighlight %}
```
Jekyll provides hooks for <code>:site</code>, <code>:pages</code>,
<code>:posts</code>, and <code>:documents</code>. In all cases, Jekyll calls your
hooks with the container object as the first callback parameter. But in the
case of <code>:pre_render</code>, your hook will also receive a payload hash as
a second parameter which allows you full control over the variables that are
available while rendering.
<code>:posts</code>, and <code>:documents</code>. In all cases, Jekyll calls
your hooks with the container object as the first callback parameter. However,
all `:pre_render` hooks and the`:site, :post_render` hook will also provide a
payload hash as a second parameter. In the case of `:pre_render`, the payload
gives you full control over the variables that are available while rendering.
In the case of `:site, :post_render`, the payload contains final values after
rendering all the site (useful for sitemaps, feeds, etc).
The complete list of available hooks is below:
@ -908,6 +910,8 @@ LESS.js files during generation.
- [Jekyll Autoprefixer](https://github.com/vwochnik/jekyll-autoprefixer): Autoprefixer integration for Jekyll
- [Jekyll-breadcrumbs](https://github.com/git-no/jekyll-breadcrumbs): Creates breadcrumbs for Jekyll 3.x, includes features like SEO optimization, optional breadcrumb item translation and more.
- [generator-jekyllized](https://github.com/sondr3/generator-jekyllized): A Yeoman generator for rapidly developing sites with Gulp. Live reload your site, automatically minify and optimize your assets and much more.
- [Jekyll-Spotify](https://github.com/MertcanGokgoz/Jekyll-Spotify): Easily output Spotify Embed Player for jekyll
- [jekyll-menus](https://github.com/forestryio/jekyll-menus): Hugo style menus for your Jekyll site... recursive menus included.
#### Editors

View File

@ -27,18 +27,18 @@ To create a new post, all you need to do is create a file in the `_posts`
directory. How you name files in this folder is important. Jekyll requires blog
post files to be named according to the following format:
{% highlight shell %}
```sh
YEAR-MONTH-DAY-title.MARKUP
{% endhighlight %}
```
Where `YEAR` is a four-digit number, `MONTH` and `DAY` are both two-digit
numbers, and `MARKUP` is the file extension representing the format used in the
file. For example, the following are examples of valid post filenames:
{% highlight shell %}
```sh
2011-12-31-new-years-eve-is-awesome.md
2012-09-12-how-to-write-a-blog.textile
{% endhighlight %}
2012-09-12-how-to-write-a-blog.md
```
<div class="note">
<h5>ProTip™: Link to other posts</h5>
@ -90,16 +90,16 @@ variable in a post.
Including an image asset in a post:
{% highlight text %}
```text
... which is shown in the screenshot below:
![My helpful screenshot]({% raw %}{{ site.url }}{% endraw %}/assets/screenshot.jpg)
{% endhighlight %}
```
Linking to a PDF for readers to download:
{% highlight text %}
```text
... you can [get the PDF]({% raw %}{{ site.url }}{% endraw %}/assets/mydoc.pdf) directly.
{% endhighlight %}
```
<div class="note">
<h5>ProTip™: Link using just the site root URL</h5>
@ -119,7 +119,7 @@ you have a list of posts somewhere. Creating an index of posts on another page
language](https://docs.shopify.com/themes/liquid/basics) and its tags. Heres a
basic example of how to create a list of links to your blog posts:
{% highlight html %}
```html
<ul>
{% raw %}{% for post in site.posts %}{% endraw %}
<li>
@ -127,7 +127,7 @@ basic example of how to create a list of links to your blog posts:
</li>
{% raw %}{% endfor %}{% endraw %}
</ul>
{% endhighlight %}
```
Of course, you have full control over how (and where) you display your posts,
and how you structure your site. You should read more about [how templates
@ -146,7 +146,7 @@ Take the above example of an index of posts. Perhaps you want to include
a little hint about the post's content by adding the first paragraph of each of
your posts:
{% highlight html %}
```html
<ul>
{% raw %}{% for post in site.posts %}{% endraw %}
<li>
@ -155,22 +155,22 @@ your posts:
</li>
{% raw %}{% endfor %}{% endraw %}
</ul>
{% endhighlight %}
```
Because Jekyll grabs the first paragraph you will not need to wrap the excerpt
in `p` tags, which is already done for you. These tags can be removed with the
following if you'd prefer:
{% highlight html %}
```html
{% raw %}{{ post.excerpt | remove: '<p>' | remove: '</p>' }}{% endraw %}
{% endhighlight %}
```
If you don't like the automatically-generated post excerpt, it can be
explicitly overridden by adding an `excerpt` value to your post's YAML
Front Matter. Alternatively, you can choose to define a custom
`excerpt_separator` in the post's YAML front matter:
{% highlight text %}
```text
---
excerpt_separator: <!--more-->
---
@ -178,7 +178,7 @@ excerpt_separator: <!--more-->
Excerpt
<!--more-->
Out-of-excerpt
{% endhighlight %}
```
You can also set the `excerpt_separator` globally in your `_config.yml`
configuration file.
@ -197,7 +197,7 @@ Jekyll also has built-in support for syntax highlighting of code snippets using
either Pygments or Rouge, and including a code snippet in any post is easy.
Just use the dedicated Liquid tag as follows:
{% highlight text %}
```text
{% raw %}{% highlight ruby %}{% endraw %}
def show
@widget = Widget(params[:id])
@ -207,11 +207,11 @@ def show
end
end
{% raw %}{% endhighlight %}{% endraw %}
{% endhighlight %}
```
And the output will look like this:
{% highlight ruby %}
```ruby
def show
@widget = Widget(params[:id])
respond_to do |format|
@ -219,7 +219,7 @@ def show
format.json { render json: @widget }
end
end
{% endhighlight %}
```
<div class="note">
<h5>ProTip™: Show line numbers</h5>

View File

@ -6,14 +6,14 @@ permalink: /docs/quickstart/
For the impatient, here's how to get a boilerplate Jekyll site up and running.
{% highlight shell %}
~ $ gem install jekyll
```sh
~ $ gem install jekyll bundler
~ $ jekyll new myblog
~ $ cd myblog
~/myblog $ bundle install
~/myblog $ bundle exec jekyll serve
# => Now browse to http://localhost:4000
{% endhighlight %}
```
If you wish to install jekyll into an existing directory, you can do so by running `jekyll new .` from within the directory instead of creating a new one. If the existing directory isn't empty, you'll also have to pass the `--force` option like so `jekyll new . --force`.

View File

@ -26,6 +26,7 @@ Jekylls growing use is producing a wide variety of tutorials, frameworks, ext
- [Jekyll Bootstrap](http://jekyllbootstrap.com), 0 to Blog in 3 minutes. Provides detailed explanations, examples, and helper-code to make getting started with Jekyll easier.
- [Integrating Twitter with Jekyll](http://www.justkez.com/integrating-twitter-with-jekyll/)
> “Having migrated Justkez.com to be based on Jekyll, I was pondering how I might include my recent twitterings on the front page of the site. In the WordPress world, this would have been done via a plugin which may or may not have hung the loading of the page, might have employed caching, but would certainly have had some overheads. … Not in Jekyll.”
- [Staticman](https://staticman.net): Add user-generated content to a Jekyll site (free and open source)
### Other commentary

View File

@ -14,12 +14,12 @@ product.
A basic Jekyll site usually looks something like this:
{% highlight shell %}
```sh
.
├── _config.yml
├── _drafts
| ├── begin-with-the-crazy-ideas.textile
| └── on-simplicity-in-technology.markdown
| ├── begin-with-the-crazy-ideas.md
| └── on-simplicity-in-technology.md
├── _includes
| ├── footer.html
| └── header.html
@ -27,14 +27,14 @@ A basic Jekyll site usually looks something like this:
| ├── default.html
| └── post.html
├── _posts
| ├── 2007-10-29-why-every-programmer-should-play-nethack.textile
| └── 2009-04-26-barcamp-boston-4-roundup.textile
| ├── 2007-10-29-why-every-programmer-should-play-nethack.md
| └── 2009-04-26-barcamp-boston-4-roundup.md
├── _data
| └── members.yml
├── _site
├── .jekyll-metadata
└── index.html
{% endhighlight %}
```
An overview of what each of these does:

View File

@ -263,7 +263,7 @@ common tasks easier.
</td>
<td class="align-center">
<p>
<code class="filter">{% raw %}{{ "a \n b" | normalize_whitepace }}{% endraw %}</code>
<code class="filter">{% raw %}{{ "a \n b" | normalize_whitespace }}{% endraw %}</code>
</p>
</td>
</tr>
@ -374,9 +374,9 @@ The default is `default`. They are as follows (with what they filter):
If you have small page fragments that you wish to include in multiple places on
your site, you can use the `include` tag.
{% highlight liquid %}
```liquid
{% raw %}{% include footer.html %}{% endraw %}
{% endhighlight %}
```
Jekyll expects all include files to be placed in an `_includes` directory at the
root of your source directory. This will embed the contents of
@ -395,23 +395,23 @@ root of your source directory. This will embed the contents of
You can also pass parameters to an include. Omit the quotation marks to send a variable's value. Liquid curly brackets should not be used here:
{% highlight liquid %}
```liquid
{% raw %}{% include footer.html param="value" variable-param=page.variable %}{% endraw %}
{% endhighlight %}
```
These parameters are available via Liquid in the include:
{% highlight liquid %}
```liquid
{% raw %}{{ include.param }}{% endraw %}
{% endhighlight %}
```
#### Including files relative to another file
You can also choose to include file fragments relative to the current file:
{% highlight liquid %}
```liquid
{% raw %}{% include_relative somedir/footer.html %}{% endraw %}
{% endhighlight %}
```
You won't need to place your included content within the `_includes` directory. Instead,
the inclusion is specifically relative to the file where the tag is being used. For example,
@ -437,7 +437,7 @@ languages](http://pygments.org/languages/)
To render a code block with syntax highlighting, surround your code as follows:
{% highlight liquid %}
```liquid
{% raw %}
{% highlight ruby %}
def foo
@ -445,7 +445,7 @@ def foo
end
{% endhighlight %}
{% endraw %}
{% endhighlight %}
```
The argument to the `highlight` tag (`ruby` in the example above) is the
language identifier. To find the appropriate identifier to use for the language
@ -460,7 +460,7 @@ Including the `linenos` argument will force the highlighted code to include line
numbers. For instance, the following code block would include line numbers next
to each line:
{% highlight liquid %}
```liquid
{% raw %}
{% highlight ruby linenos %}
def foo
@ -468,7 +468,7 @@ def foo
end
{% endhighlight %}
{% endraw %}
{% endhighlight %}
```
#### Stylesheets for syntax highlighting
@ -488,21 +488,21 @@ specify.
You must include the file extension when using the `link` tag.
{% highlight liquid %}
```liquid
{% raw %}
{% link _collection/name-of-document.md %}
{% link _posts/2016-07-26-name-of-post.md %}
{% endraw %}
{% endhighlight %}
```
You can also use this tag to create a link in Markdown as follows:
{% highlight liquid %}
```liquid
{% raw %}
[Link to a document]({% link _collection/name-of-document.md %})
[Link to a post]({% link _posts/2016-07-26-name-of-post.md %})
{% endraw %}
{% endhighlight %}
```
Support for static files and pages is coming in a later release but is
**not** released as of v3.2.1.
@ -512,49 +512,49 @@ Support for static files and pages is coming in a later release but is
If you would like to include a link to a post on your site, the `post_url` tag
will generate the correct permalink URL for the post you specify.
{% highlight liquid %}
```liquid
{% raw %}
{% post_url 2010-07-21-name-of-post %}
{% endraw %}
{% endhighlight %}
```
If you organize your posts in subdirectories, you need to include subdirectory
path to the post:
{% highlight liquid %}
```liquid
{% raw %}
{% post_url /subdir/2010-07-21-name-of-post %}
{% endraw %}
{% endhighlight %}
```
There is no need to include the file extension when using the `post_url` tag.
You can also use this tag to create a link to a post in Markdown as follows:
{% highlight liquid %}
```liquid
{% raw %}
[Name of Link]({% post_url 2010-07-21-name-of-post %})
{% endraw %}
{% endhighlight %}
```
### Gist
Use the `gist` tag to easily embed a GitHub Gist onto your site. This works
with public or secret gists:
{% highlight liquid %}
```liquid
{% raw %}
{% gist parkr/931c1c8d465a04042403 %}
{% endraw %}
{% endhighlight %}
```
You may also optionally specify the filename in the gist to display:
{% highlight liquid %}
```liquid
{% raw %}
{% gist parkr/931c1c8d465a04042403 jekyll-private-gist.markdown %}
{% endraw %}
{% endhighlight %}
```
To use the `gist` tag, you'll need to add the
[jekyll-gist](https://github.com/jekyll/jekyll-gist) gem to your project.

View File

@ -27,6 +27,7 @@ Jekyll themes set default layouts, includes, and stylesheets, that can be overri
Jekyll will look first to your site's content, before looking to the theme's defaults, for any requested file in the following folders:
* `/assets`
* `/_layouts`
* `/_includes`
* `/_sass`
@ -34,11 +35,15 @@ Jekyll will look first to your site's content, before looking to the theme's def
Refer to your selected theme's documentation and source repository for more information on what files you can override.
{: .note .info}
To locate theme's files on your computer, run `bundle show` followed by
the name of the theme's gem, e.g. `bundle show minima` for default Jekyll's
theme. Then copy the files you want to override, from the returned path to your root folder.
## Creating a theme
Jekyll themes are distributed as Ruby gems. Don't worry, Jekyll will help you scaffold a new theme with the `new-theme` command. Just run `jekyll new-theme` with the theme name as an argument:
{% highlight plaintext %}
```sh
jekyll new-theme my-awesome-theme
create /path/to/my-awesome-theme/_layouts
create /path/to/my-awesome-theme/_includes
@ -54,7 +59,7 @@ jekyll new-theme my-awesome-theme
create /path/to/my-awesome-theme/.gitignore
Your new Jekyll theme, my-awesome-theme, is ready for you in /path/to/my-awesome-theme!
For help getting started, read /path/to/my-awesome-theme/README.md.
{% endhighlight %}
```
Add your template files in the corresponding folders, complete the `.gemspec` and the README files according to your needs.
@ -64,6 +69,12 @@ Theme layouts and includes work just like they work in any Jekyll site. Place la
For example, if your theme has a `/_layouts/page.html` file, and a page has `layout: page` in its YAML front matter, Jekyll will first look to the site's `_layouts` folder for a the `page` layout, and if none exists, will use your theme's `page` layout.
### Assets
Any file in `/assets` will be copied over to the user's site upon build unless they have a file with the same relative path. You may ship any kind of asset here: SCSS, an image, a webfont, etc. These files behave just like pages and static files in Jekyll: if the file has [YAML front matter]({{ site.baseurl }}/docs/frontmatter/) at the top, then it will be rendered. If it does not have YAML front matter, it will simply be copied over into the resulting site. This allows theme creators to ship a default `/assets/styles.scss` file which their layouts can depend on as `/assets/styles.css`.
All files in `/assets` will be output into the compiled site in the `/assets` folder just as you'd expect from using Jekyll on your sites.
### Stylesheets
Your theme's stylesheets should be placed in your theme's `/_sass` folder, again, just as you would when authoring a Jekyll site. Your theme's styles can be included in the user's stylesheet using the `@import` directive.
@ -94,3 +105,6 @@ Themes are published via [RubyGems.org](https://rubygems.org). You'll need a Rub
2. Next, push your packaged theme up to the RubyGems service, by running the following command, again replacing `my-awesome-jekyll-theme` with the name of your theme:
gem push my-awesome-jekyll-theme-*.gem
3. To release a new version of your theme, simply update the version number in the gemspec file, ( `my-awesome-jekyll-theme.gemspec` in this example ), and then repeat Steps 1 & 2 above.
We recommend that you follow [Semantic Versioning](http://semver.org/) while bumping your theme-version.

View File

@ -13,6 +13,7 @@ that might be of help. If the problem youre experiencing isnt covered belo
- [Base-URL Problems](#base-url-problems)
- [Configuration problems](#configuration-problems)
- [Markup Problems](#markup-problems)
- [Production Problems](#production-problems)
## Installation Problems
@ -20,61 +21,61 @@ If you encounter errors during gem installation, you may need to install
the header files for compiling extension modules for Ruby 2.0.0. This
can be done on Ubuntu or Debian by running:
{% highlight shell %}
```sh
sudo apt-get install ruby2.0.0-dev
{% endhighlight %}
```
On Red Hat, CentOS, and Fedora systems you can do this by running:
{% highlight shell %}
```sh
sudo yum install ruby-devel
{% endhighlight %}
```
If you installed the above - specifically on Fedora 23 - but the extensions would still not compile, you are probably running a Fedora image that misses the `redhat-rpm-config` package. To solve this, simply run:
{% highlight shell %}
```sh
sudo dnf install redhat-rpm-config
{% endhighlight %}
```
On [NearlyFreeSpeech](https://www.nearlyfreespeech.net/) you need to run the
following commands before installing Jekyll:
{% highlight shell %}
```sh
export GEM_HOME=/home/private/gems
export GEM_PATH=/home/private/gems:/usr/local/lib/ruby/gems/1.8/
export PATH=$PATH:/home/private/gems/bin
export RB_USER_INSTALL='true'
{% endhighlight %}
```
To install RubyGems on Gentoo:
{% highlight shell %}
```sh
sudo emerge -av dev-ruby/rubygems
{% endhighlight %}
```
On Windows, you may need to install [RubyInstaller
DevKit](https://wiki.github.com/oneclick/rubyinstaller/development-kit).
On Mac OS X, you may need to update RubyGems (using `sudo` only if necessary):
{% highlight shell %}
```sh
sudo gem update --system
{% endhighlight %}
```
If you still have issues, you can download and install new Command Line
Tools (such as `gcc`) using the command
{% highlight shell %}
```sh
xcode-select --install
{% endhighlight %}
```
which may allow you to install native gems using this command (again using
`sudo` only if necessary):
{% highlight shell %}
```sh
sudo gem install jekyll
{% endhighlight %}
```
Note that upgrading Mac OS X does not automatically upgrade Xcode itself
(that can be done separately via the App Store), and having an out-of-date
@ -90,22 +91,22 @@ longer available. Given these changes, there are a couple of simple ways to get
up and running. One option is to change the location where the gem will be
installed (again using `sudo` only if necessary):
{% highlight shell %}
```sh
sudo gem install -n /usr/local/bin jekyll
{% endhighlight %}
```
Alternatively, Homebrew can be installed and used to set up Ruby. This can be
done as follows:
{% highlight shell %}
```sh
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
{% endhighlight %}
```
Once Homebrew is installed, the second step is easy:
{% highlight shell %}
```sh
brew install ruby
{% endhighlight %}
```
Advanced users (with more complex needs) may find it helpful to choose one of a
number of Ruby version managers ([RVM][], [rbenv][], [chruby][], [etc][].) in
@ -119,15 +120,15 @@ which to install Jekyll.
If you elect to use one of the above methods to install Ruby, it might be
necessary to modify your `$PATH` variable using the following command:
{% highlight shell %}
```sh
export PATH=/usr/local/bin:$PATH
{% endhighlight %}
```
GUI apps can modify the `$PATH` as follows:
{% highlight shell %}
```sh
launchctl setenv PATH "/usr/local/bin:$PATH"
{% endhighlight %}
```
Either of these approaches are useful because `/usr/local` is considered a
"safe" location on systems which have SIP enabled, they avoid potential
@ -151,21 +152,21 @@ in order to have the `jekyll` executable be available in your Terminal.
If you are using base-url option like:
{% highlight shell %}
```sh
jekyll serve --baseurl '/blog'
{% endhighlight %}
```
… then make sure that you access the site at:
{% highlight shell %}
```sh
http://localhost:4000/blog/index.html
{% endhighlight %}
```
It wont work to just access:
{% highlight shell %}
```sh
http://localhost:4000/blog
{% endhighlight %}
```
## Configuration problems
@ -180,6 +181,11 @@ That is: defaults are overridden by options specified in `_config.yml`,
and flags specified at the command-line will override all other settings
specified elsewhere.
If you encounter an error in building the site, with the error message
"'0000-00-00-welcome-to-jekyll.markdown.erb' does not have a valid date in the
YAML front matter." try including the line `exclude: [vendor]`
in `_config.yml`.
## Markup Problems
The various markup engines that Jekyll uses may have some issues. This
@ -192,9 +198,9 @@ The latest version, version 2.0, seems to break the use of `{{ "{{" }}` in
templates. Unlike previous versions, using `{{ "{{" }}` in 2.0 triggers the
following error:
{% highlight shell %}
```sh
'{{ "{{" }}' was not properly terminated with regexp: /\}\}/ (Liquid::SyntaxError)
{% endhighlight %}
```
### Excerpts
@ -204,6 +210,13 @@ strange errors where references don't exist or a tag hasn't been closed. If you
run into these errors, try setting `excerpt_separator: ""` in your
`_config.yml`, or set it to some nonsense string.
## Production Problems
If you run into an issue that a static file can't be found in your
production environment during build since v3.2.0 you should set your
[environment to `production`](../configuration/#specifying-a-jekyll-environment-at-build-time).
The issue is caused by trying to copy a non-existing symlink.
<div class="note">
<h5>Please report issues you encounter!</h5>
<p>

View File

@ -9,9 +9,9 @@ and 2.0 that you'll want to know about.
Before we dive in, go ahead and fetch the latest version of Jekyll:
{% highlight shell %}
```sh
$ gem update jekyll
{% endhighlight %}
```
<div class="note feature">
<h5 markdown="1">Diving in</h5>

View File

@ -9,9 +9,9 @@ that you'll want to know about.
Before we dive in, go ahead and fetch the latest version of Jekyll:
{% highlight shell %}
```sh
$ gem update jekyll
{% endhighlight %}
```
Please note: Jekyll 3 requires Ruby version >= 2.0.0.
@ -36,11 +36,11 @@ When iterating over `site.collections`, ensure the above conversions are made.
For `site.collections.myCollection` in Jekyll 2, you now do:
{% highlight liquid %}
```liquid
{% raw %}
{% assign myCollection = site.collections | where: "label", "myCollection" | first %}
{% endraw %}
{% endhighlight %}
```
This is a bit cumbersome at first, but is easier than a big `for` loop.
@ -97,17 +97,17 @@ In Jekyll 3 and above, relative permalinks have been deprecated. If you
created your site using Jekyll 2 and below, you may receive the following
error when trying to **serve** or **build**:
{% highlight text %}
```text
Since v3.0, permalinks for pages in subfolders must be relative to the site
source directory, not the parent directory. Check
http://jekyllrb.com/docs/upgrading/ for more info.
{% endhighlight %}
```
This can be fixed by removing the following line from your `_config.yml` file:
{% highlight yaml %}
```yaml
relative_permalinks: true
{% endhighlight %}
```
### Permalinks no longer automatically add a trailing slash
@ -117,19 +117,19 @@ In Jekyll 2, any URL constructed from the `permalink:` field had a trailing slas
Try adding `future: true` to your `_config.yml` file. Are they showing up now? If they are, then you were ensnared by an issue with the way Ruby parses times. Each of your posts is being read in a different timezone than you might expect and, when compared to the computer's current time, is "in the future." The fix for this is to add [a timezone offset](https://en.wikipedia.org/wiki/List_of_UTC_time_offsets) to each post (and make sure you remove `future: true` from your `_config.yml` file). If you're writing from California, for example, you would change this:
{% highlight yaml %}
```yaml
---
date: 2016-02-06 19:32:10
---
{% endhighlight %}
```
to this (note the offset):
{% highlight yaml %}
```yaml
---
date: 2016-02-06 19:32:10 -0800
---
{% endhighlight %}
```
### My categories have stopped working!

View File

@ -7,7 +7,7 @@ permalink: /docs/usage/
The Jekyll gem makes a `jekyll` executable available to you in your Terminal
window. You can use this command in a number of ways:
{% highlight shell %}
```sh
$ jekyll build
# => The current folder will be generated into ./_site
@ -20,7 +20,7 @@ $ jekyll build --source <source> --destination <destination>
$ jekyll build --watch
# => The current folder will be generated into ./_site,
# watched for changes, and regenerated automatically.
{% endhighlight %}
```
<div class="note info">
<h5>Changes to _config.yml are not included during automatic regeneration.</h5>
@ -52,7 +52,7 @@ $ jekyll build --watch
Jekyll also comes with a built-in development server that will allow you to
preview what the generated site will look like in your browser locally.
{% highlight shell %}
```sh
$ jekyll serve
# => A development server will run at http://localhost:4000/
# Auto-regeneration: enabled. Use `--no-watch` to disable.
@ -61,7 +61,7 @@ $ jekyll serve --detach
# => Same as `jekyll serve` but will detach from the current terminal.
# If you need to kill the server, you can `kill -9 1234` where "1234" is the PID.
# If you cannot find the PID, then do, `ps aux | grep jekyll` and kill the instance. [Read more](http://unixhelp.ed.ac.uk/shell/jobz5.html).
{% endhighlight %}
```
<div class="note info">
<h5>Be aware of default behavior</h5>
@ -70,10 +70,10 @@ $ jekyll serve --detach
</p>
</div>
{% highlight shell %}
```sh
$ jekyll serve --no-watch
# => Same as `jekyll serve` but will not watch for changes.
{% endhighlight %}
```
These are just a few of the available [configuration options](../configuration/).
Many configuration options can either be specified as flags on the command line,
@ -82,17 +82,17 @@ file at the root of the source directory. Jekyll will automatically use the
options from this file when run. For example, if you place the following lines
in your `_config.yml` file:
{% highlight yaml %}
```yaml
source: _source
destination: _deploy
{% endhighlight %}
```
Then the following two commands will be equivalent:
{% highlight shell %}
```sh
$ jekyll build
$ jekyll build --source _source --destination _deploy
{% endhighlight %}
```
For more about the possible configuration options, see the
[configuration](../configuration/) page.

View File

@ -115,8 +115,7 @@ following is a reference of the available data.
If the page being processed is a Post, this contains a list of up to ten
related Posts. By default, these are the ten most recent posts.
For high quality but slow to compute results, run the
<code>jekyll</code> command with the <code>--lsi</code> (latent semantic
indexing) option. Also note GitHub Pages does not support the <code>lsi</code> option when generating sites.
<code>jekyll</code> command with the <code>--lsi</code> (<a href="https://en.wikipedia.org/wiki/Latent_semantic_analysis#Latent_semantic_indexing">latent semantic indexing</a>) option. Also note GitHub Pages does not support the <code>lsi</code> option when generating sites.
</p></td>
</tr>

View File

@ -29,9 +29,9 @@ Additionally, you might need to change the code page of the console window to UT
in case you get a "Liquid Exception: Incompatible character encoding" error during
the site generation process. It can be done with the following command:
{% highlight shell %}
```sh
$ chcp 65001
{% endhighlight %}
```
[windows-installation]: http://jekyll-windows.juthilo.com/
[hitimes-issue]: https://github.com/copiousfreetime/hitimes/issues/40
@ -43,9 +43,9 @@ As of v1.3.0, Jekyll uses the `listen` gem to watch for changes when the
built-in support for UNIX systems, it requires an extra gem for compatibility
with Windows. Add the following to the Gemfile for your site:
{% highlight ruby %}
```ruby
gem 'wdm', '~> 0.1.0' if Gem.win_platform?
{% endhighlight %}
```
### How to install github-pages
@ -81,7 +81,7 @@ This gem is also needed in the github-pages and to get it running on Windows x64
`choco install libiconv -Source "https://www.nuget.org/api/v2/"`{:.language-ruby}
{% highlight ruby %}
```ruby
gem install nokogiri --^
--with-xml2-include=C:\Chocolatey\lib\libxml2.2.7.8.7\build\native\include^
--with-xml2-lib=C:\Chocolatey\lib\libxml2.redist.2.7.8.7\build\native\bin\v110\x64\Release\dynamic\cdecl^
@ -89,7 +89,7 @@ This gem is also needed in the github-pages and to get it running on Windows x64
--with-iconv-lib=C:\Chocolatey\lib\libiconv.redist.1.14.0.11\build\native\bin\v110\x64\Release\dynamic\cdecl^
--with-xslt-include=C:\Chocolatey\lib\libxslt.1.1.28.0\build\native\include^
--with-xslt-lib=C:\Chocolatey\lib\libxslt.redist.1.1.28.0\build\native\bin\v110\x64\Release\dynamic
{% endhighlight %}
```
#### Install github-pages
@ -98,10 +98,10 @@ This gem is also needed in the github-pages and to get it running on Windows x64
* Copy & paste the two lines into the file:
{% highlight ruby %}
```ruby
source 'http://rubygems.org'
gem 'github-pages'
{% endhighlight %}
```
* **Note:** We use an unsecure connection because SSL throws exceptions in the version of Ruby
* Open a command prompt, target your local blog repository root, and install github-pages: `bundle install`

View File

@ -1,5 +1,5 @@
{% for item in include.items %}
{% assign item_url = item | prepend:"/docs/" | append:"/" %}
{% assign doc = site.docs | where: "url", item_url | first %}
<option value="{{ site.url }}{{ doc.url }}">{{ doc.title }}</option>
<option value="{{ doc.url }}">{{ doc.title }}</option>
{% endfor %}

View File

@ -2,6 +2,6 @@
{% for item in include.items %}
{% assign item_url = item | prepend:"/docs/" | append:"/" %}
{% assign p = site.docs | where:"url", item_url | first %}
<li class="{% if item_url == page.url %}current{% endif %}"><a href="{{ site.url }}{{ p.url }}">{{ p.title }}</a></li>
<li class="{% if item_url == page.url %}current{% endif %}"><a href="{{ p.url }}">{{ p.title }}</a></li>
{% endfor %}
</ul>

View File

@ -0,0 +1,18 @@
---
layout: news_item
title: "Jekyll Admin Initial Release"
date: "2016-08-25 09:50:00 +0300"
author: mertkahyaoglu
categories: [community]
---
[Jekyll's Google Summer of Code Project](http://jekyllrb.com/news/2016/06/03/update-on-jekyll-s-google-summer-of-code-projects/) has concluded. After three months of hard (but fun) work with my mentors @benbalter, @jldec, and @parkr, I'm proud to announce [Jekyll Admin](https://github.com/jekyll/jekyll-admin)'s [initial release](https://github.com/jekyll/jekyll-admin/releases/tag/v0.1.0). Jekyll admin is a Jekyll plugin that provides users with a traditional CMS-style graphical interface to author content and administer Jekyll sites. You can start to use it right away by following [these instructions](https://github.com/jekyll/jekyll-admin#installation).
As a Google Summer of Code student, I feel very lucky to be part of a project that the community has been wanting for such a long time. The three-month Google Summer of Code period was a great journey. It was a lot of fun developing the project and seeing how it could help the community, and going forward, we are really excited to see where the project goes with the help of the amazing Jekyll community.
I would like to thank my mentors who embraced me as their teammate and guided me throughout the process. They have put a lot of work and time to mentor me and helped me with everything. It was a great pleasure to work with them. I also would like to thank the wonderful Jekyll community for making Jekyll what it is today. It was amazing to see the community contribute to the project and give their feedback
prior to its release. I'm sure that they will support Jekyll Admin as much as they can and move Jekyll even further.
Please let us know what you think about [Jekyll Admin](https://github.com/jekyll/jekyll-admin) and feel free to [contribute](https://github.com/jekyll/jekyll-admin/blob/master/.github/CONTRIBUTING.md). Your feedback and contributions are greatly appreciated.
Happy (graphical) Jekylling!

View File

@ -673,6 +673,12 @@ h5 > code,
overflow: auto;
}
.highlighter-rouge .highlight {
@extend .highlight;
margin: 0;
padding: 10px 0.5em;
}
/* HTML Elements */
h1, h2, h3, h4, h5, h6 { margin: 0; }

View File

@ -45,7 +45,7 @@ overview: true
<p class="line">
<span class="path">~</span>
<span class="prompt">$</span>
<span class="command">gem install jekyll</span>
<span class="command">gem install jekyll bundler</span>
</p>
<p class="line">
<span class="path">~</span>

View File

@ -0,0 +1,3 @@
.sample {
color: red;
}

View File

@ -0,0 +1,3 @@
---
---
alert "From your theme."

View File

@ -0,0 +1 @@
logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -0,0 +1,3 @@
---
---
@import "test-theme-{{ site.theme-color | default: "red" }}";

View File

@ -120,12 +120,9 @@ class JekyllUnitTest < Minitest::Test
"destination" => dest_dir,
"incremental" => false
}))
build_configs({
Configuration.from(full_overrides.merge({
"source" => source_dir
}, full_overrides)
.fix_common_issues
.backwards_compatibilize
.add_default_collections
}))
end
def clear_dest

View File

@ -0,0 +1,3 @@
---
---
alert "From your site."

7
test/source/info.md Normal file
View File

@ -0,0 +1,7 @@
---
title: Information
---
# Information
Very important information is here

View File

@ -8,23 +8,28 @@ class TestFilters < JekyllUnitTest
attr_accessor :site, :context
def initialize(opts = {})
@site = Jekyll::Site.new(
Jekyll.configuration(opts.merge("skip_config_files" => true))
)
@site = Jekyll::Site.new(opts.merge("skip_config_files" => true))
@context = Liquid::Context.new({}, {}, { :site => @site })
end
end
def make_filter_mock(opts = {})
JekyllFilter.new(site_configuration(opts)).tap do |f|
tz = f.site.config["timezone"]
Jekyll.set_timezone(tz) if tz
end
end
class SelectDummy
def select; end
end
context "filters" do
setup do
@filter = JekyllFilter.new({
"source" => source_dir,
"destination" => dest_dir,
"timezone" => "UTC"
@filter = make_filter_mock({
"timezone" => "UTC",
"url" => "http://example.com",
"baseurl" => "/base"
})
@sample_time = Time.utc(2013, 3, 27, 11, 22, 33)
@sample_date = Date.parse("2013-03-27")
@ -65,7 +70,7 @@ class TestFilters < JekyllUnitTest
end
should "escapes special characters when configured to do so" do
kramdown = JekyllFilter.new({ :kramdown => { :entity_output => :symbolic } })
kramdown = make_filter_mock({ :kramdown => { :entity_output => :symbolic } })
assert_equal(
"&ldquo;This filter&rsquo;s test&hellip;&rdquo;",
kramdown.smartify(%q{"This filter's test..."})
@ -307,6 +312,99 @@ class TestFilters < JekyllUnitTest
assert_equal "my%20things", @filter.uri_escape("my things")
end
context "absolute_url filter" do
should "produce an absolute URL from a page URL" do
page_url = "/about/my_favorite_page/"
assert_equal "http://example.com/base#{page_url}", @filter.absolute_url(page_url)
end
should "ensure the leading slash" do
page_url = "about/my_favorite_page/"
assert_equal "http://example.com/base/#{page_url}", @filter.absolute_url(page_url)
end
should "ensure the leading slash for the baseurl" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => "base"
})
assert_equal "http://example.com/base/#{page_url}", filter.absolute_url(page_url)
end
should "be ok with a blank but present 'url'" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock({
"url" => "",
"baseurl" => "base"
})
assert_equal "/base/#{page_url}", filter.absolute_url(page_url)
end
should "be ok with a nil 'url'" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock({
"url" => nil,
"baseurl" => "base"
})
assert_equal "/base/#{page_url}", filter.absolute_url(page_url)
end
should "be ok with a nil 'baseurl'" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => nil
})
assert_equal "http://example.com/#{page_url}", filter.absolute_url(page_url)
end
should "not prepend a forward slash if input is empty" do
page_url = ""
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => "/base"
})
assert_equal "http://example.com/base", filter.absolute_url(page_url)
end
end
context "relative_url filter" do
should "produce a relative URL from a page URL" do
page_url = "/about/my_favorite_page/"
assert_equal "/base#{page_url}", @filter.relative_url(page_url)
end
should "ensure the leading slash between baseurl and input" do
page_url = "about/my_favorite_page/"
assert_equal "/base/#{page_url}", @filter.relative_url(page_url)
end
should "ensure the leading slash for the baseurl" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock({ "baseurl" => "base" })
assert_equal "/base/#{page_url}", filter.relative_url(page_url)
end
should "be ok with a nil 'baseurl'" do
page_url = "about/my_favorite_page/"
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => nil
})
assert_equal "/#{page_url}", filter.relative_url(page_url)
end
should "not prepend a forward slash if input is empty" do
page_url = ""
filter = make_filter_mock({
"url" => "http://example.com",
"baseurl" => "/base"
})
assert_equal "/base", filter.relative_url(page_url)
end
end
context "jsonify filter" do
should "convert hash to json" do
assert_equal "{\"age\":18}", @filter.jsonify({ :age => 18 })
@ -475,7 +573,7 @@ class TestFilters < JekyllUnitTest
g["items"].is_a?(Array),
"The list of grouped items for '' is not an Array."
)
assert_equal 13, g["items"].size
assert_equal 15, g["items"].size
end
end
end

View File

@ -40,9 +40,12 @@ class TestNewCommand < JekyllUnitTest
should "display a success message" do
Jekyll::Commands::New.process(@args)
output = Jekyll.logger.messages.last
output = Jekyll.logger.messages[-3]
output_last = Jekyll.logger.messages.last
success_message = "New jekyll site installed in #{@full_path.cyan}."
bundle_message = "Running bundle install in #{@full_path.cyan}..."
assert_includes output, success_message
assert_includes output_last, bundle_message
end
should "copy the static files in site template to the new directory" do
@ -85,7 +88,10 @@ class TestNewCommand < JekyllUnitTest
should "create blank project" do
blank_contents = %w(/_drafts /_layouts /_posts /index.html)
capture_stdout { Jekyll::Commands::New.process(@args, "--blank") }
output = Jekyll.logger.messages.last
bundle_message = "Running bundle install in #{@full_path.cyan}..."
assert_same_elements blank_contents, dir_contents(@full_path)
refute_includes output, bundle_message
end
should "force created folder" do
@ -93,6 +99,13 @@ class TestNewCommand < JekyllUnitTest
output = capture_stdout { Jekyll::Commands::New.process(@args, "--force") }
assert_match(%r!New jekyll site installed in!, output)
end
should "skip bundle install when opted to" do
capture_stdout { Jekyll::Commands::New.process(@args, "--skip-bundle") }
output = Jekyll.logger.messages.last
bundle_message = "Bundle install skipped."
assert_includes output, bundle_message
end
end
context "when multiple args are given" do

View File

@ -13,8 +13,8 @@ class TestRelatedPosts < JekyllUnitTest
last_post = @site.posts.last
related_posts = Jekyll::RelatedPosts.new(last_post).build
last_10_recent_posts = (@site.posts.docs.reverse - [last_post]).first(10)
assert_equal last_10_recent_posts, related_posts
last_ten_recent_posts = (@site.posts.docs.reverse - [last_post]).first(10)
assert_equal last_ten_recent_posts, related_posts
end
end

View File

@ -180,6 +180,7 @@ class TestSite < JekyllUnitTest
%#\ +.md
.htaccess
about.html
application.coffee
bar.html
coffeescript.coffee
contacts.html
@ -191,6 +192,7 @@ class TestSite < JekyllUnitTest
humans.txt
index.html
index.html
info.md
main.scss
main.scss
properties.html
@ -489,6 +491,34 @@ class TestSite < JekyllUnitTest
end
end
context "when setting theme" do
should "set no theme if config is not set" do
expect($stderr).not_to receive(:puts)
expect($stdout).not_to receive(:puts)
site = fixture_site({ "theme" => nil })
assert_nil site.theme
end
should "set no theme if config is a hash" do
output = capture_output do
site = fixture_site({ "theme" => {} })
assert_nil site.theme
end
expected_msg = "Theme: value of 'theme' in config should be String " \
"to use gem-based themes, but got Hash\n"
assert output.end_with?(expected_msg),
"Expected #{output.inspect} to end with #{expected_msg.inspect}"
end
should "set a theme if the config is a string" do
expect($stderr).not_to receive(:puts)
expect($stdout).not_to receive(:puts)
site = fixture_site({ "theme" => "test-theme" })
assert_instance_of Jekyll::Theme, site.theme
assert_equal "test-theme", site.theme.name
end
end
context "with liquid profiling" do
setup do
@site = Site.new(site_configuration("profile" => true))

View File

@ -12,6 +12,7 @@ class TestTags < JekyllUnitTest
site.posts.docs.concat(PostReader.new(site).read_posts("")) if override["read_posts"]
CollectionReader.new(site).read if override["read_collections"]
site.read if override["read_all"]
info = { :filters => [Jekyll::Filters], :registers => { :site => site } }
@converter = site.converters.find { |c| c.class == converter_class }
@ -58,6 +59,7 @@ CONTENT
assert_match r, "xml+cheetah"
assert_match r, "x.y"
assert_match r, "coffee-script"
assert_match r, "shell_session"
refute_match r, "blah^"
@ -627,6 +629,41 @@ CONTENT
end
end
context "simple page with linking to a page" do
setup do
content = <<CONTENT
---
title: linking
---
{% link contacts.html %}
{% link info.md %}
{% link /css/screen.css %}
CONTENT
create_post(content, {
"source" => source_dir,
"destination" => dest_dir,
"read_all" => true
})
end
should "not cause an error" do
refute_match(%r!markdown\-html\-error!, @result)
end
should "have the URL to the \"contacts\" item" do
assert_match(%r!/contacts\.html!, @result)
end
should "have the URL to the \"info\" item" do
assert_match(%r!/info\.html!, @result)
end
should "have the URL to the \"screen.css\" item" do
assert_match(%r!/css/screen\.css!, @result)
end
end
context "simple page with linking" do
setup do
content = <<CONTENT

View File

@ -34,16 +34,16 @@ class TestTheme < JekyllUnitTest
end
context "path generation" do
[:layouts, :includes, :sass].each do |folder|
[:assets, :_layouts, :_includes, :_sass].each do |folder|
should "know the #{folder} path" do
expected = File.expand_path("_#{folder}", @expected_root)
assert_equal expected, @theme.public_send("#{folder}_path")
expected = File.expand_path(folder.to_s, @expected_root)
assert_equal expected, @theme.public_send("#{folder.to_s.tr("_", "")}_path")
end
end
should "generate folder paths" do
expected = File.expand_path("./_sass", @expected_root)
assert_equal expected, @theme.send(:path_for, :sass)
assert_equal expected, @theme.send(:path_for, :_sass)
end
should "not allow paths outside of the theme root" do
@ -56,7 +56,7 @@ class TestTheme < JekyllUnitTest
should "return the resolved path when a symlink & resolved path exists" do
expected = File.expand_path("./_layouts", @expected_root)
assert_equal expected, @theme.send(:path_for, :symlink)
assert_equal expected, @theme.send(:path_for, :_symlink)
end
end

View File

@ -0,0 +1,71 @@
require "helper"
class TestThemeAssetsReader < JekyllUnitTest
def setup
@site = fixture_site(
"theme" => "test-theme",
"theme-color" => "black"
)
assert @site.theme
end
def assert_file_with_relative_path(haystack, relative_path)
assert haystack.any? { |f|
f.relative_path == relative_path
}, "Site should read in the #{relative_path} file, " \
"but it was not found in #{haystack.inspect}"
end
def refute_file_with_relative_path(haystack, relative_path)
refute haystack.any? { |f|
f.relative_path == relative_path
}, "Site should not have read in the #{relative_path} file, " \
"but it was found in #{haystack.inspect}"
end
context "with a valid theme" do
should "read all assets" do
@site.reset
ThemeAssetsReader.new(@site).read
assert_file_with_relative_path @site.static_files, "assets/img/logo.png"
assert_file_with_relative_path @site.pages, "assets/style.scss"
end
should "convert pages" do
@site.process
file = @site.pages.find { |f| f.relative_path == "assets/style.scss" }
refute_nil file
assert_equal @site.in_dest_dir("assets/style.css"), file.destination(@site.dest)
assert_includes file.output, ".sample {\n color: black; }"
end
should "not overwrite site content with the same relative path" do
@site.reset
@site.read
file = @site.pages.find { |f| f.relative_path == "assets/application.coffee" }
refute_nil file
assert_includes file.content, "alert \"From your site.\""
end
end
context "with a valid theme without an assets dir" do
should "not read any assets" do
site = fixture_site("theme" => "test-theme")
allow(site.theme).to receive(:assets_path).and_return(nil)
ThemeAssetsReader.new(site).read
refute_file_with_relative_path site.static_files, "assets/img/logo.png"
refute_file_with_relative_path site.pages, "assets/style.scss"
end
end
context "with no theme" do
should "not read any assets" do
site = fixture_site("theme" => nil)
ThemeAssetsReader.new(site).read
refute_file_with_relative_path site.static_files, "assets/img/logo.png"
refute_file_with_relative_path site.pages, "assets/style.scss"
end
end
end

View File

@ -198,6 +198,13 @@ class TestUtils < JekyllUnitTest
)
end
should "replace everything else but ASCII characters" do
assert_equal "the-config-yml-file",
Utils.slugify("The _config.yml file?", :mode => "ascii")
assert_equal "f-rtive-glance",
Utils.slugify("fürtive glance!!!!", :mode => "ascii")
end
should "only replace whitespace if mode is raw" do
assert_equal(
"the-_config.yml-file?",