Finally Migrated to Octopress

, par  Marius Ducea , popularité : 2%

For a while now, I wanted to migrate my blog from Wordpress to Octopress, but for some reason I kept putting it on the shelf and not doing it. (let’s say because of all those client related projects…). Finally last weekend I’ve completed the migration and I’m really excited to get back to blogging after this. This post is meant to capture some of the issues I’ve encountered during the migration and how to fix them. This is not a full how to migrate post, as there are many such great articles available already.

Migrate old blog posts.

Believe it or not, I had 364 blog posts when I started the migration. Meaning a lot of energy was spent in importing those old articles. I’ve used exitwp to convert the wordpress-xml export of the blog posts ; and this produced a reasonably good result. Still I had to run some fixes…

  • for code blocks :
1
<span> perl -pi -e 's/([^`]|^)(`)([^`]|$)/$1\n```\n$3/g' *</span>
  • to enable comments (as ‘comments : true’ was missing from all posts)
1
2
<span>find source/_posts/ -type f -print0 | xargs -0 -I file sed -i '' '2 i \
</span><span>  comments: true' file</span>

Categories/Tags/URLs

Enabled the octopress category list plugin and tags plugin, that you can see in the sidebar. Since I had already tags and categories on all posts it was very important to keep the same urls and not break them. Same thing for regular posts urls. Here are the relevant settings form the octopress config file :

1
2
3
4
5
6
<span>root: /
</span><span>permalink: /:year/:month/:day/:title/
</span><span>
</span><span>category_dir: category
</span><span>
</span><span>tag_dir: "tag"
</span>

Just keep in mind that if you have many tags as I do, the generation of the pages will increase a lot after you enable the tags plugin. You’ve been warned !

Disqus comments

Not working at all… I’ve wrote a post specifically about this ; check it out here

Feed Url

My wordpress blog has been around for a while (6years more or less) and even if I’ve always used feedburner for my feed, but for some strange reason I’ve always used my own feed url. This of course was no longer working with octopress, hence I had to setup a rewrite rule to not break everyone’s feed reader :

1
2
3
4
5
<span><span>RewriteEngine</span> <span>On</span>
</span><span><span>Options</span> +FollowSymLinks -Multiviews
</span><span>
</span><span><span># Feed url</span>
</span><span><span>RewriteRule</span> ^feed/?$ atom.xml [QSA,L]
</span>

Rewrite non-www to www

This was done automatically by wordpress, but octopress will serve just fine the non-www domain. This can cause issues with search engines and such, so I wanted the same behaviour. Apache again to the rescue :

1
2
<span><span>RewriteCond</span> %{HTTP_HOST} !^www [NC]
</span><span><span>RewriteRule</span> $ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R]
</span>

Apache optimizations, caching, compression, etc

After you generated your octopress site, everything is static and fast by default. Still, you want to make sure that apache has some basic caching and compression settings to make it even better. Here are the relevant parts from my config :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<span><span>#### CACHING ####</span>
</span><span><span>&lt;IfModule</span> <span>mod_expires.c</span><span>&gt;</span>
</span><span><span>ExpiresActive</span> <span>On</span>
</span><span>
</span><span><span># 1 MONTH</span>
</span><span><span>&lt;FilesMatch</span> <span>"\.(ico|gif|jpe?g|png|flv|pdf|swf|mov|mp3|wmv|ppt)$"</span><span>&gt;</span>
</span><span>  <span>ExpiresDefault</span> A2419200
</span><span>  <span>Header</span> append Cache-Control <span>"public"</span>
</span><span><span>&lt;/FilesMatch&gt;</span>
</span><span>
</span><span><span># 3 DAYS</span>
</span><span><span>&lt;FilesMatch</span> <span>"\.(xml|txt|html|htm|js|css)$"</span><span>&gt;</span>
</span><span>  <span>ExpiresDefault</span> A259200
</span><span>  <span>Header</span> append Cache-Control <span>"private, must-revalidate"</span>
</span><span><span>&lt;/FilesMatch&gt;</span>
</span><span>
</span><span><span># NEVER CACHE</span>
</span><span><span>&lt;FilesMatch</span> <span>"\.(php|cgi|pl)$"</span><span>&gt;</span>
</span><span>  <span>ExpiresDefault</span> A0
</span><span>  <span>Header</span> set Cache-Control <span>"no-store, no-cache, must-revalidate, max-age=0"</span>
</span><span>  <span>Header</span> set Pragma <span>"no-cache"</span>
</span><span><span>&lt;/FilesMatch&gt;</span>
</span><span><span>&lt;/IfModule&gt;</span>
</span><span>
</span><span><span>### Compression ####</span>
</span><span><span>&lt;IfModule</span> <span>mod_deflate.c</span><span>&gt;</span>
</span><span>    <span>&lt;IfModule</span> <span>mod_setenvif.c</span><span>&gt;</span>
</span><span>        <span>BrowserMatch</span> ^Mozilla/4 gzip-only-text/html
</span><span>        <span>BrowserMatch</span> ^Mozilla/4\.0[678] no-gzip
</span><span>        <span>BrowserMatch</span> \bMSIE !no-gzip !gzip-only-text/html
</span><span>        <span>BrowserMatch</span> \bMSI[E] !no-gzip !gzip-only-text/html
</span><span>    <span>&lt;/IfModule&gt;</span>
</span><span>    <span>&lt;IfModule</span> <span>mod_headers.c</span><span>&gt;</span>
</span><span>        <span>Header</span> append Vary <span>User</span>-Agent env=!dont-vary
</span><span>    <span>&lt;/IfModule&gt;</span>
</span><span>    <span>&lt;IfModule</span> <span>mod_filter.c</span><span>&gt;</span>
</span><span>        <span>AddOutputFilterByType</span> DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
</span><span>    <span>&lt;/IfModule&gt;</span>
</span><span><span>&lt;/IfModule&gt;</span>
</span>

Isolated when working on a new post

If you have many posts, the generation of the octopress site will be extremely slow (in my case it takes about 2mins for a full generate) and this makes it basically impossible to work with any new post and see the feedback locally with preview. The solution is well documented and it works by isolating your single post while working on it, and when you are done you integrate back all the other posts before publishing them :

1
2
<span><span>rake</span> new_post['Finally Migrated to Octopress']
</span><span><span>rake</span> isolate[finally-migrated-to-octopress]
</span>

and now rake generate and rake preview will only work with the new post. Finally when done and ready to publish the awesome new post on the internets :

1
2
3
<span><span>rake</span> integrate
</span><span><span>rake</span> generate
</span><span><span>rake</span> deploy
</span>

Others

  • some small customisations to the theme (colours and such)
  • about me and contact custom asides.
  • fix the github aside (updated to work with their latest api version and actually return the repos)
  • and of course the contact form (using a wufoo form)

Mdlog?d=yIl2AUoC8zA

Mdlog?i=0SwgX9uVe_Y:1k1tWl9e4WA:F7zBnMyn Mdlog?i=0SwgX9uVe_Y:1k1tWl9e4WA:V_sGLiPB Mdlog?d=qj6IDK7rITs Mdlog?i=0SwgX9uVe_Y:1k1tWl9e4WA:gIN9vFwO

Cet article est repris du site http://feedproxy.google.com/~r/Mdlo...

Sites favoris Tous les sites

84 sites référencés dans ce secteur