Skip to content

Commit f81bdbc

Browse files
committed
Added support and documentation for deploying to subdirectories (like
with gh-pages)
1 parent 4855ef5 commit f81bdbc

File tree

11 files changed

+42
-16
lines changed

11 files changed

+42
-16
lines changed

.themes/classic/plugins/category_generator.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ module Filters
129129
# Returns string
130130
#
131131
def category_links(categories)
132+
dir = @context.registers[:site].config['category_dir']
133+
root_url = @context.registers[:site].config['root']
132134
categories = categories.sort!.map do |item|
133-
"<a class='category' href='/#{@context.registers[:site].config['category_dir']}/#{item.gsub(/_|\W/, '-')}/'>#{item}</a>"
135+
"<a class='category' href='#{root_url}/#{dir}/#{item.gsub(/_|\W/, '-')}/'>#{item}</a>"
134136
end
135137

136138
case categories.length

.themes/classic/source/_includes/archive_post.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% capture category %}{{ post.categories | size }}{% endcapture %}
2-
<h1><a href="{{ post.url }}">{{post.title}}</a></h1>
2+
<h1><a href="{{ site.root }}{{ post.url }}">{{post.title}}</a></h1>
33
<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>
44
{% if category != '0' %}
55
<footer>

.themes/classic/source/_includes/article.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% unless page.no_header %}
22
<header>
33
{% if index %}
4-
<h1 class="entry-title"><a href="{{ post.url }}">{{ post.title | titlecase }}</a></h1>
4+
<h1 class="entry-title"><a href="{{ site.root }}{{ post.url }}">{{ post.title | titlecase }}</a></h1>
55
{% else %}
66
<h1 class="entry-title">{{ page.title | titlecase }}</h1>
77
{% endif %}
@@ -13,7 +13,7 @@ <h1 class="entry-title">{{ page.title | titlecase }}</h1>
1313
{% if index %}
1414
<div class="entry-content">{{ content | exerpt | smart_quotes }}</div>
1515
<footer>
16-
<a rel="full-article" href="{{ post.url }}">Read on &rarr;</a>
16+
<a rel="full-article" href="{{ site.root }}{{ post.url }}">Read on &rarr;</a>
1717
</footer>
1818
{% else %}
1919
<div class="entry-content">{{ content | smart_quotes }}</div>

.themes/classic/source/_includes/asides/pinboard.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h1>My Pinboard</h1>
1212
var pinboardInit = document.createElement('script');
1313
pinboardInit.type = 'text/javascript';
1414
pinboardInit.async = true;
15-
pinboardInit.src = '/javascripts/pinboard.js';
15+
pinboardInit.src = '{{ site.root }}/javascripts/pinboard.js';
1616
document.getElementsByTagName('head')[0].appendChild(pinboardInit);
1717
})();
1818
</script>

.themes/classic/source/_includes/asides/recent_posts.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ <h1>Recent Posts</h1>
33
<ul id="recent_posts">
44
{% for post in site.posts limit: site.recent_posts %}
55
<li class="post">
6-
<a href="{{ post.url }}">{{ post.title }}</a>
6+
<a href="{{ site.root }}{{ post.url }}">{{ post.title }}</a>
77
</li>
88
{% endfor %}
99
</ul>

.themes/classic/source/_includes/asides/twitter.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h1>Latest Tweets</h1>
99
getTwitterFeed("{{site.twitter_user}}", {{site.twitter_tweet_count}}, {{site.twitter_show_replies}});
1010
});
1111
</script>
12-
<script src="/javascripts/twitter.js" type="text/javascript"> </script>
12+
<script src="{{ site.root }}/javascripts/twitter.js" type="text/javascript"> </script>
1313
{% if site.twitter_follow_button %}
1414
<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>
1515
{% else %}

.themes/classic/source/_includes/head.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
<meta name="keywords" content="{{page.keywords}}"/>
2020
{% endif %}
2121

22-
<link href="/images/favicon.png" rel="shortcut icon" />
23-
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
24-
<script src="/javascripts/modernizr-2.0.js"></script>
22+
<link href="{{ site.url }}/images/favicon.png" rel="shortcut icon" />
23+
<link href="{{ site.url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
24+
<script src="{{ site.url }}/javascripts/modernizr-2.0.js"></script>
2525
<script src="http://s3.amazonaws.com/ender-js/jeesh.min.js"></script>
26-
<script src="/javascripts/octopress.js" type="text/javascript"></script>
26+
<script src="{{ site.url }}/javascripts/octopress.js" type="text/javascript"></script>
2727
<link href='http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
2828
<link href='http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
29-
<link href="/atom.xml" rel="alternate" title="{{site.title}}" type="application/atom+xml"/>
29+
<link href="{{ site.url }}/atom.xml" rel="alternate" title="{{site.title}}" type="application/atom+xml"/>
3030
{% include google_analytics.html %}
3131
{% include google_plus_one.html %}
3232
{% include twitter_sharing.html %}

.themes/classic/source/_includes/header.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<hgroup>
2-
<h1><a href="/">{{ site.title }}</a></h1>
2+
<h1><a href="{{ site.root }}">{{ site.title }}</a></h1>
33
{% if site.subtitle %}
44
<h2>{{ site.subtitle }}</h2>
55
{% endif %}

.themes/classic/source/_includes/navigation.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
</fieldset>
1212
</form>
1313
<ul role="main-nav">
14-
<li><a href="/">Blog</a></li>
15-
<li><a href="/blog/archives">Archives</a></li>
14+
<li><a href="{{ site.root }}/">Blog</a></li>
15+
<li><a href="{{ site.root }}/blog/archives">Archives</a></li>
1616
</ul>

README.markdown

+17
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,23 @@ The `config_deploy` rake task takes a branch name as an argument and creates a [
118118
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.
119119
Github will queue your site for publishing (which usually occurs instantly or within minutes if it's your first commit).
120120

121+
**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.
122+
123+
For Octopress my cofigs would be set up like this:
124+
125+
# _config.yaml
126+
destination: public/octopress
127+
url: http://imathis.github.com/octopress
128+
subscribe_rss: /octopress/atom.xml
129+
root: /octopress
130+
131+
# config.rb
132+
http_path = "/octopress"
133+
134+
# Rakefile
135+
public_dir = "public/octopress"
136+
137+
121138
## License
122139
(The MIT License)
123140

_config.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,14 @@ recent_posts: 5
2222
category_dir: blog/categories
2323
simple_search: http://google.com/search
2424

25-
# Optional configurations
25+
# ----------------------- #
26+
# Optional configurations #
27+
# ----------------------- #
28+
29+
# If publishing to a subdirectory as in http://site.com/project set this:
30+
# root: /project
31+
# If left blank, urls will be mapped to '/'
32+
root:
2633

2734
# RSS feeds can list your email address if you like
2835
email:

0 commit comments

Comments
 (0)