Added support and documentation for deploying to subdirectories (like

with gh-pages)
This commit is contained in:
Brandon Mathis 2011-07-16 09:29:09 -04:00
parent 4855ef5d2f
commit f81bdbc1a8
11 changed files with 42 additions and 16 deletions

View File

@ -129,8 +129,10 @@ module Jekyll
# Returns string # Returns string
# #
def category_links(categories) def category_links(categories)
dir = @context.registers[:site].config['category_dir']
root_url = @context.registers[:site].config['root']
categories = categories.sort!.map do |item| categories = categories.sort!.map do |item|
"<a class='category' href='/#{@context.registers[:site].config['category_dir']}/#{item.gsub(/_|\W/, '-')}/'>#{item}</a>" "<a class='category' href='#{root_url}/#{dir}/#{item.gsub(/_|\W/, '-')}/'>#{item}</a>"
end end
case categories.length case categories.length

View File

@ -1,5 +1,5 @@
{% capture category %}{{ post.categories | size }}{% endcapture %} {% capture category %}{{ post.categories | size }}{% endcapture %}
<h1><a href="{{ post.url }}">{{post.title}}</a></h1> <h1><a href="{{ site.root }}{{ post.url }}">{{post.title}}</a></h1>
<time datetime="{{ post.date | datetime }}" pubdate>{{ post.date | date: "<span class='month'>%b</span> <span class='day'>%d</span> <span class='year'>%Y</span>"}}</time> <time datetime="{{ post.date | datetime }}" pubdate>{{ post.date | date: "<span class='month'>%b</span> <span class='day'>%d</span> <span class='year'>%Y</span>"}}</time>
{% if category != '0' %} {% if category != '0' %}
<footer> <footer>

View File

@ -1,7 +1,7 @@
{% unless page.no_header %} {% unless page.no_header %}
<header> <header>
{% if index %} {% if index %}
<h1 class="entry-title"><a href="{{ post.url }}">{{ post.title | titlecase }}</a></h1> <h1 class="entry-title"><a href="{{ site.root }}{{ post.url }}">{{ post.title | titlecase }}</a></h1>
{% else %} {% else %}
<h1 class="entry-title">{{ page.title | titlecase }}</h1> <h1 class="entry-title">{{ page.title | titlecase }}</h1>
{% endif %} {% endif %}
@ -13,7 +13,7 @@
{% if index %} {% if index %}
<div class="entry-content">{{ content | exerpt | smart_quotes }}</div> <div class="entry-content">{{ content | exerpt | smart_quotes }}</div>
<footer> <footer>
<a rel="full-article" href="{{ post.url }}">Read on &rarr;</a> <a rel="full-article" href="{{ site.root }}{{ post.url }}">Read on &rarr;</a>
</footer> </footer>
{% else %} {% else %}
<div class="entry-content">{{ content | smart_quotes }}</div> <div class="entry-content">{{ content | smart_quotes }}</div>

View File

@ -12,7 +12,7 @@
var pinboardInit = document.createElement('script'); var pinboardInit = document.createElement('script');
pinboardInit.type = 'text/javascript'; pinboardInit.type = 'text/javascript';
pinboardInit.async = true; pinboardInit.async = true;
pinboardInit.src = '/javascripts/pinboard.js'; pinboardInit.src = '{{ site.root }}/javascripts/pinboard.js';
document.getElementsByTagName('head')[0].appendChild(pinboardInit); document.getElementsByTagName('head')[0].appendChild(pinboardInit);
})(); })();
</script> </script>

View File

@ -3,7 +3,7 @@
<ul id="recent_posts"> <ul id="recent_posts">
{% for post in site.posts limit: site.recent_posts %} {% for post in site.posts limit: site.recent_posts %}
<li class="post"> <li class="post">
<a href="{{ post.url }}">{{ post.title }}</a> <a href="{{ site.root }}{{ post.url }}">{{ post.title }}</a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>

View File

@ -9,7 +9,7 @@
getTwitterFeed("{{site.twitter_user}}", {{site.twitter_tweet_count}}, {{site.twitter_show_replies}}); getTwitterFeed("{{site.twitter_user}}", {{site.twitter_tweet_count}}, {{site.twitter_show_replies}});
}); });
</script> </script>
<script src="/javascripts/twitter.js" type="text/javascript"> </script> <script src="{{ site.root }}/javascripts/twitter.js" type="text/javascript"> </script>
{% if site.twitter_follow_button %} {% if site.twitter_follow_button %}
<a href="http://twitter.com/{{ site.twitter_user }}" class="twitter-follow-button" data-width="208px" data-show-count="{{ site.twitter_show_follower_count }}">Follow @{{ site.twitter_user }}</a> <a href="http://twitter.com/{{ site.twitter_user }}" class="twitter-follow-button" data-width="208px" data-show-count="{{ site.twitter_show_follower_count }}">Follow @{{ site.twitter_user }}</a>
{% else %} {% else %}

View File

@ -19,14 +19,14 @@
<meta name="keywords" content="{{page.keywords}}"/> <meta name="keywords" content="{{page.keywords}}"/>
{% endif %} {% endif %}
<link href="/images/favicon.png" rel="shortcut icon" /> <link href="{{ site.url }}/images/favicon.png" rel="shortcut icon" />
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css"> <link href="{{ site.url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="/javascripts/modernizr-2.0.js"></script> <script src="{{ site.url }}/javascripts/modernizr-2.0.js"></script>
<script src="http://s3.amazonaws.com/ender-js/jeesh.min.js"></script> <script src="http://s3.amazonaws.com/ender-js/jeesh.min.js"></script>
<script src="/javascripts/octopress.js" type="text/javascript"></script> <script src="{{ site.url }}/javascripts/octopress.js" type="text/javascript"></script>
<link href='http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'> <link href='http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
<link href="/atom.xml" rel="alternate" title="{{site.title}}" type="application/atom+xml"/> <link href="{{ site.url }}/atom.xml" rel="alternate" title="{{site.title}}" type="application/atom+xml"/>
{% include google_analytics.html %} {% include google_analytics.html %}
{% include google_plus_one.html %} {% include google_plus_one.html %}
{% include twitter_sharing.html %} {% include twitter_sharing.html %}

View File

@ -1,5 +1,5 @@
<hgroup> <hgroup>
<h1><a href="/">{{ site.title }}</a></h1> <h1><a href="{{ site.root }}">{{ site.title }}</a></h1>
{% if site.subtitle %} {% if site.subtitle %}
<h2>{{ site.subtitle }}</h2> <h2>{{ site.subtitle }}</h2>
{% endif %} {% endif %}

View File

@ -11,6 +11,6 @@
</fieldset> </fieldset>
</form> </form>
<ul role="main-nav"> <ul role="main-nav">
<li><a href="/">Blog</a></li> <li><a href="{{ site.root }}/">Blog</a></li>
<li><a href="/blog/archives">Archives</a></li> <li><a href="{{ site.root }}/blog/archives">Archives</a></li>
</ul> </ul>

View File

@ -118,6 +118,23 @@ The `config_deploy` rake task takes a branch name as an argument and creates a [
This prepares your branch for easy deployment. The `rake deploy` task copies the generated blog from the `public` directory to the `_deploy` directory, adds new files, removes old files, sets a commit message, and pushes to Github. This prepares your branch for easy deployment. The `rake deploy` task copies the generated blog from the `public` directory to the `_deploy` directory, adds new files, removes old files, sets a commit message, and pushes to Github.
Github will queue your site for publishing (which usually occurs instantly or within minutes if it's your first commit). Github will queue your site for publishing (which usually occurs instantly or within minutes if it's your first commit).
**Please note,** Github's project pages will be published to a subdirectory and you'll have to make sure you set up your urls correctly in your configs.
For Octopress my cofigs would be set up like this:
# _config.yaml
destination: public/octopress
url: http://imathis.github.com/octopress
subscribe_rss: /octopress/atom.xml
root: /octopress
# config.rb
http_path = "/octopress"
# Rakefile
public_dir = "public/octopress"
## License ## License
(The MIT License) (The MIT License)

View File

@ -22,7 +22,14 @@ recent_posts: 5
category_dir: blog/categories category_dir: blog/categories
simple_search: http://google.com/search simple_search: http://google.com/search
# Optional configurations # ----------------------- #
# Optional configurations #
# ----------------------- #
# If publishing to a subdirectory as in http://site.com/project set this:
# root: /project
# If left blank, urls will be mapped to '/'
root:
# RSS feeds can list your email address if you like # RSS feeds can list your email address if you like
email: email: