According to Octopress’s official documentation, the command for generating a new post is like this.1
$ rake new_post["title"]
How about including some symbols inside
Single quotation marks
As you can see from the documentation, simply enclosing it with a pair of double quotes will do.
Double quotation marks
The following shell command works.
$ rake new_post['testing "double" quotes'] # Creates source/_posts/2014-05-31-testing-double-quotes.markdown
However, as I ran
rake generate, I encountered an error.
$ rake generate (in /home/owner/octopress) ## Generating Site with Jekyll unchanged sass/print.scss identical source/stylesheets/screen.css Configuration from /home/owner/octopress/_config.yml Building site: source -> public ERROR: YOUR SITE COULD NOT BE BUILT: ------------------------------------ (<unknown>): did not find expected key while parsing a block mapping at line 2 column 1 in /home/owner/octopress/source/_posts/2014-05-31-testing-double- quotes.markdown
view its contents.
1 2 3 4 5 6 7 8 9
At line 3 of the faulty markdown file, escaping the
" inside the
outer pair of double quotes with
\ can resolve the problem.
title: "testing \"double\" quotes"
When I started writing the post My Desktop Crashed!, I attempted typing the following command.
$ rake new_post["My Desktop Crashed!"] bash: !"]: event not found
The solution is again simple: changing
Exclamation marks and quotes
Before writing Internet Explorer a Security Risk: Use Firefox or Chrome, I tried issuing the following command.
$ rake new_post["Don't use Internet Explorer\!"] (in /home/owner/octopress) mkdir -p source/_posts Creating new post: source/_posts/2014-05-31-dont-use-internet-explorer-slash.markdown
Although the above command works, the link of the new post doesn’t
look great. Therefore, we have to avoid using backslashes inside the
square brackets This time, there’s an apostrophe inside the title,
so we can’t use
' to surround
!. To create such kind of posts,
some simple tricks will do.
- Pass a title with
', but without
$ rake new_post["Don't use Internet Explorer"] # Creates source/_posts/2014-05-31-dont-use-internet-explorer.markdown
- Add the things back to
titlein the header of the generated markdown file.
- For example, change
title: "Don't use Internet Explorer"into
title: "Don't use Internet Explorer!"
- For example, change