Skip to content
Browse files

1. Added rake task for simple configuration of subdirectory deployment.

2. Updated READEME documentation regarding deploying to subdirectories.
3. Fixed related mistake in pagination and header links
  • Loading branch information...
imathis committed Jul 16, 2011
1 parent f81bdbc commit 1f9b596b821685edcdaebaa885b1c6a4a22d1487
Showing with 78 additions and 18 deletions.
  1. +5 −5 .themes/classic/source/_includes/head.html
  2. +4 −4 .themes/classic/source/index.html
  3. +29 −5 README.markdown
  4. +34 −1 Rakefile
  5. +6 −3 config.rb
@@ -19,14 +19,14 @@
<meta name="keywords" content="{{page.keywords}}"/>
{% endif %}

<link href="{{ site.url }}/images/favicon.png" rel="shortcut icon" />
<link href="{{ site.url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="{{ site.url }}/javascripts/modernizr-2.0.js"></script>
<link href="{{ site.root }}/images/favicon.png" rel="shortcut icon" />
<link href="{{ site.root }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="{{ site.root }}/javascripts/modernizr-2.0.js"></script>
<script src=""></script>
<script src="{{ site.url }}/javascripts/octopress.js" type="text/javascript"></script>
<script src="{{ site.root }}/javascripts/octopress.js" type="text/javascript"></script>
<link href=',italic,bold,bolditalic' rel='stylesheet' type='text/css'>
<link href=',italic,bold,bolditalic' rel='stylesheet' type='text/css'>
<link href="{{ site.url }}/atom.xml" rel="alternate" title="{{site.title}}" type="application/atom+xml"/>
<link href="{{ site.root }}/atom.xml" rel="alternate" title="{{site.title}}" type="application/atom+xml"/>
{% include google_analytics.html %}
{% include google_plus_one.html %}
{% include twitter_sharing.html %}
@@ -13,13 +13,13 @@
<nav role="pagination">
{% if paginator.next_page %}
<a class="prev" href="/page{{paginator.next_page}}/">&larr; Older</a>
<a class="prev" href="{{ site.root }}/page{{paginator.next_page}}/">&larr; Older</a>
{% endif %}
<a href="/blog/archives">Blog Archives</a>
<a href="{{ site.root }}/blog/archives">Blog Archives</a>
{% if paginator.previous_page and paginator.previous_page > 1 %}
<a class="next" href="/page{{paginator.previous_page}}/">Newer &rarr;</a>
<a class="next" href="{{ site.root }}/page{{paginator.previous_page}}/">Newer &rarr;</a>
{% elsif paginator.previous_page %}
<a class="next" href="/">Newer &rarr;</a>
<a class="next" href="{{ site.root }}/">Newer &rarr;</a>
{% endif %}
@@ -118,22 +118,46 @@ 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.
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:
### Deploying to a Subdirectory (Github Project Pages does this)
# _config.yaml
If you're deploying to a subdirectory on your site, or if you're using Github's project pages, make sure you set up your urls correctly in your configs.
You can do this automatically:
rake set_root_dir[your/path]
# To go back to publishing to the document root
rake set_root_dir[/]
Then update your `_config.yml` and `Rakefile` as follows:
# Change the url in _config.yml
# If deploying with rsync, update your Rakefile path
document_root = "~/"
To manually configure deployment to a subdirectory, you'll change `_config.yml`, `config.rb` and `Rakefile`
# Example for deploying to Octopress's Github Pages
# _config.yml
destination: public/octopress
subscribe_rss: /octopress/atom.xml
root: /octopress
# config.rb
# config.rb - for Compass & Sass
http_path = "/octopress"
http_images_path = "/octopress/images"
http_fonts_path = "/octopress/fonts"
css_dir = "public/octopress/stylesheets"
# Rakefile
public_dir = "public/octopress"
# If deploying with rsync, update your Rakefile path
document_root = "~/"
## License
(The MIT License)
@@ -124,7 +124,40 @@ task :push do

desc "setup _deploy folder and deploy branch"
desc "Update configurations to support publishing to root or sub directory"
task :set_root_dir, :dir do |t, args|
puts ">>> !! Please provide a directory, eg. rake config_dir[publishing/subdirectory]" unless args.dir
if args.dir
if args.dir == "/"
dir = ""
dir = "/" + args.dir.sub(/(\/*)(.+)/, "\\2").sub(/\/$/, '');
rakefile =
rakefile.sub!(/public_dir(\s*)=(\s*)(["'])[\w\-\/]*["']/, "public_dir\\1=\\2\\3public#{dir}\\3"), 'w') do |f|
f.write rakefile
compass_config ='config.rb')
compass_config.sub!(/http_path(\s*)=(\s*)(["'])[\w\-\/]*["']/, "http_path\\1=\\2\\3#{dir}/\\3")
compass_config.sub!(/http_images_path(\s*)=(\s*)(["'])[\w\-\/]*["']/, "http_images_path\\1=\\2\\3#{dir}/images\\3")
compass_config.sub!(/http_fonts_path(\s*)=(\s*)(["'])[\w\-\/]*["']/, "http_fonts_path\\1=\\2\\3#{dir}/fonts\\3")
compass_config.sub!(/css_dir(\s*)=(\s*)(["'])[\w\-\/]*["']/, "css_dir\\1=\\2\\3public#{dir}/stylesheets\\3")'config.rb', 'w') do |f|
f.write compass_config
jekyll_config ='_config.yml')
jekyll_config.sub!(/^destination:.+$/, "destination: public#{dir}")
jekyll_config.sub!(/^subscribe_rss:.+$/, "subscribe_rss: #{dir}/atom.xml")
jekyll_config.sub!(/^root:.*$/, "root: #{dir}")'_config.yml', 'w') do |f|
f.write jekyll_config
mkdir_p "public#{dir}"

desc "Setup _deploy folder and deploy branch"
task :config_deploy, :branch do |t, args|
puts "!! Please provide a deploy branch, eg. rake init_deploy[gh-pages] !!" unless args.branch
puts "## Creating a clean #{args.branch} branch in ./#{deploy_dir} for Github pages deployment"
@@ -1,13 +1,16 @@
# Require any additional compass plugins here.
project_type = :stand_alone
# Set this to the root of your project when deployed:

# Publishing paths
http_path = "/"
http_images_path = "/images"
http_fonts_path = "/fonts"
css_dir = "public/stylesheets"

# Local development paths
sass_dir = "sass"
images_dir = "source/images"
http_images_dir = "images"
fonts_dir = "source/fonts"
http_fonts_dir = "fonts"

line_comments = false
output_style = :compressed

0 comments on commit 1f9b596

Please sign in to comment.
You can’t perform that action at this time.