Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6894229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:45:24+00:00 2026-05-27T06:45:24+00:00

I have a task in my Rakefile for creating a new post in Jekyll.

  • 0

I have a task in my Rakefile for creating a new post in Jekyll. (I borrowed it from Octopress).

I’ve tried to hack it so that it will create a new markdown file, add the default header info and then open it in IA Writer. It creates the file and adds the info, but what it opens isn’t the file. It looks like the filename variable isn’t being passed through to the system command, but I have no idea how I should be writing it.

Here’s the code:

# Usage rake new_post['Title of the Post']
desc "Beginning a new post in _posts"
task :new_post, :title do |t, args|
  args.with_defaults(:title => 'new-post')
  title = args.title
  filename = "_posts/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.markdown"
  open_filename = "#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.markdown"
  if File.exist?(filename)
    abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
  end
  puts "Creating new post: #{filename}"
  open(filename, 'w') do |post|
    post.puts "---"
    post.puts "layout: post"
    post.puts "title: \"#{title.gsub(/&/,'&')}\""
    post.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
    post.puts "categories: "
    post.puts "---"
  end
  puts "Opening: #{filename}"
  system('open -a IA\ Writer ~/Dropbox/Archive/jdb/#{filename}')
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:45:25+00:00Added an answer on May 27, 2026 at 6:45 am

    In line system... change ' to ". In ' ruby doesn’t use variables, example:

    001 > filename = "test"
    => "test"
    002 > puts '#{filename}'
    => #{filename}
    003 > puts "#{filename}"
    => test
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rakefile with a Rake task that I would normally call from
I have a Rakefile that defines the spec task as task :spec => [:check_dependencies,
I have this rakefile that works fine when called from a Start Command Prompt
I am new this sharepoint development and i have task in hand to do
I have a Task object that has a collection of Label objects ... in
I want to call a rake task from a cron job that stores remote
have a problem creating my new table in SqlLite3 I have created this migration
I have a rake task that performs a shell command. When I run it
In my Rakefile, I have a task defined like this: namespace :test do desc
I have a Rakefile like this task :clean do sh 'rm ./foo' end I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.