Setting Up Octopress Blog Once You Lost the Working Env

- - posted in Technical | Tagged as Octopress,repo,octopress-plugin,octopress-migration | Comments

Hi Guys,

So recently I wanted to revisit my blog after a long long break, and I realized that my working blogging environment broke and I wanted to setup again to be able to blog from both my personal laptop and any other laptop. But to my dismay, it was not that stright forward. Luckily, I had the source folder of my blog with me. It was quite a feat, Hence I thought of documenting it through this post.

How Octopress works

Octopress repositories have two branches, source and master. The source branch contains the files that are used to generate the blog and the master contains the blog itself.

When the local folders are initially configured according to the Octopress Setup Guide, the master branch is stored in a subfolder named ‘_deploy’. Since the folder name begins with an underscore, it is ignored when you git push origin source. Instead, the master branch (which contains your blog posts) gets updated when you rake deploy.

Clone your blog to the new machine

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ git clone -b source git@github.com:username/username.github.com.git Local_octopress
$ cd Local_octopress
$ git clone git@github.com:username/username.github.com.git _deploy 
$ gem install bundler
$ rbenv rehash    # If you use rbenv, rehash to be able to run the bundle command

$ bundle install

$ rake setup_github_pages

It will prompt you for your repository URL.
Enter the read/write url for your repository
(For example, 'git@github.com:your_username/your_username.github.com)
That’s you setup with a new local copy of your Octopress blog.

Pushing changes from two different machines

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
If you want to blog from more than one computer, you need to make sure that you push everything before switching computers. 
From the first machine do the following whenever you’ve made changes:

$ rake generate
$ git add .
$ git commit -am "Some comment here." 
$ git push origin source  # update the remote source branch 
$ rake deploy             # update the remote master branch


Then on the other machine, you need to pull those changes.

$ cd octopress
$ git pull origin source  # update the local source branch
$ cd ./_deploy
$ git pull origin master  # update the local master branch

Octopress 2.0

If you were returning to blogging after so long, chances are that there were many things changed.

  1. Rubypants is removed.
  2. Include Code Tag lets you embed external code snippets from your file system and adds a download link
  3. Pullquote Tag Generate beautiful semantic pullquotes (no double data) based on Maykel Loomans's technique
  4. Category Generator gives you archive pages for each category
  5. Sitemap.xml Generator for search engines

etc. etc.

I got so many errors once I checked out a new version of Octopress. It was not supporting many of my old plugins, So I got rid of some, and I updated some.

Errors

One error I got was in date.rb of feedjira(formerly feedzira) plugin. The error message said:

1
jekyll 2.1.1 undefined method `deep_merge'

so I replaced deep_merge

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def to_liquid
          date_format = self.site.config['date_format']
      self.data.deep_merge({
          "title"             => self.data['title'] || self.slug.split('-').select {|w| w.capitalize! || w }.join(' '),
          "url"               => self.url,
          "date"              => self.date,
          # Monkey patch
          "date_formatted"    => format_date(self.date, date_format),
          "updated_formatted" => self.data.has_key?('updated') ? format_date(self.data['updated'], date_format) : nil,
          "id"                => self.id,
          "categories"        => self.categories,
          "next"              => self.next,
          "previous"          => self.previous,
          "tags"              => self.tags,
          "content"           => self.content })
  end

with the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
def to_liquid(attrs = nil)
      date_format = self.site.config['date_format']
      new_datas = {
        "title"             => self.data['title'] || self.slug.split('-').select {|w| w.capitalize! || w }.join(' '),
        "url"               => self.url,
        "date"              => self.date,
        # Monkey patch
        "date_formatted"    => format_date(self.date, date_format),
        "updated_formatted" => self.data.has_key?('updated') ? format_date(self.data['updated'], date_format) : nil,
        "id"                => self.id,
        "categories"        => self.categories,
        "next"              => self.next,
        "previous"          => self.previous,
        "tags"              => self.tags,
        "content"           => self.content }
     
      Utils.deep_merge_hashes(self.data, new_datas)
    end

Notice the use of deep_merge_hashes above.

Another error was Updates were rejected because the tip of your current branch is behind when I executed "bundle exec rake gen_deploy"

The reason is that Octopress only does a push to the master branch and not a pull. To resolve this, do this:

1
2
3
4
$$ cd _deploy
$$ git push origin master -f   # hope this solves the problem, move to next command
$$ cd ..
$$ bundle exec rake gen_deploy

Another error was in installing curl on windows. So I had to refer this And install curb manually.

1
2
3
4
5
6
7
C:\Users\AshwaniK> gem install curb  -v '0.7.18' -- --with-curl-lib=C:\libcurl\bin --with-curl-include=C:\libcurl\include
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-curl-lib=C:\libcurl\bin --with-curl-include=C:\libcurl\include'
This could take a while...
Successfully installed curb-0.7.18
Installing ri documentation for curb-0.7.18
1 gem installed

Reference Commands:

1
2
3
4
5
6
7
8
9
10
cd octopress
bundle exec rake new_post["title"]
bundle exec rake preview
bundle exec rake generate

bundle exec rake deploy

git add .
git commit -m 'site updated'
git push origin source

There were other errors which I somehow resolved.

Hope this helps someone. I might need this again, So I am keeping a refrence.

Thats all folks. Chow.

Credits to:
1. Trouble-with-cloning-octopress-blog-on-other-laptops
2. Clone Your Octopress to Blog From Two Places.
3. Blogging-with-octopress-from-2-computers/





Gravatar of Ashwani Kumar

Recent posts


Subscribe



Your Feedback encourages me




Learning and Developments

One Month Rails



, 2FA, AWS AWS, Active Authenticator Directory, Facebook Flash, Forwarding, GOD,Chat,Coffee Github,Feedback,Repo Google Google,Search HAProxy, IOT, IP-block JQuery LetsEncrypt Load MQ MQTT, Messaging Octopress Octopress, OpenVpn OpenVpn, PI, Plugin Plugin, Port Raspberry, S3, SSH, Shell,Commands Soapui, Tag Tag, Tree, Tunneling XML XML, XServer, Xming ajax, angular, animated architecture architecture, azure balancing cloud, commenting, connectivity datapower datatables diagrams diaspora dropdown geocoding grep, hashicorp, ipaddress, ipv6, java, java,python mysql nokogiri, octopress-migration octopress-plugin oidc openapi, openssl powershell proxy rails, repo reviews ruby, script scripts, security, sharepoint shell spiffe spire spring springboot, ssh, swagger, telnet, vault vi, vieditor vim, visualblock, webattacks windows,cleanup windowsxp workload identity