#!/usr/bin/ruby puts

SunDi3yansyah


puts

App Server, Database App, Web App

Cara Konfigurasi SEO Keywords Dan Deskripsi Octopress

| Comments | Cahyadi Triyansyah Cahyadi Triyansyah

SEO itu asset terpenting dalam membangun website, tanya donk kenapa? Nanti akan di jawab dengan rumput yang bergoyang. smileya.! Ya pokoknya gitu deh…

Tutorial ini akan membuat Rakefile pada ruby anda ketika membuat post menghasilkan teks sepebagi berikut:

1
2
3
4
5
6
7
8
9
---
layout: post
title: "Cara Konfigurasi SEO Keywords dan deskripsi Octopress"
date: 2014-09-10 03:49:47 +0700
comments: true
categories: 
description: 
keywords: 
---

Pertama rubah dulu file _config.yml

1
2
3
4
5
6
7
8
url: http://yoursite.com
title: My Octopress Blog
subtitle: A blogging framework for hackers.
author: Your Name
simple_search: http://google.com/search

description: "Description untuk blog anda"
keywords: "keyword1, keyword2, keyword3, dst"

Edit kurang lebih seperti diatas, jangan sama persis, tapi sesuaikan dengan blog kalian. Kalau sudah di save.

Buka file Rakefile

Tambahkan puts seperti di bawah ini:

1
2
post.puts "description: "
    post.puts "keywords: "

Di taroh dimana ya? Liat contoh dibawah

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
# usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post")
desc "Begin a new post in #{source_dir}/#{posts_dir}"
task :new_post, :title do |t, args|
  if args.title
    title = args.title
  else
    title = get_stdin("Enter a title for your post: ")
  end
  raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
  mkdir_p "#{source_dir}/#{posts_dir}"
  filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"
  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:%S %z')}"
    post.puts "comments: true"
    post.puts "categories: "
    post.puts "description: "
    post.puts "keywords: "
    post.puts "---"
  end
end

Lakukan juga untuk di new_page

Gak tau? Liat code dibawah:

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
40
# usage rake new_page[my-new-page] or rake new_page[my-new-page.html] or rake new_page (defaults to "new-page.markdown")
desc "Create a new page in #{source_dir}/(filename)/index.#{new_page_ext}"
task :new_page, :filename do |t, args|
  raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
  args.with_defaults(:filename => 'new-page')
  page_dir = [source_dir]
  if args.filename.downcase =~ /(^.+\/)?(.+)/
    filename, dot, extension = $2.rpartition('.').reject(&:empty?)         # Get filename and extension
    title = filename
    page_dir.concat($1.downcase.sub(/^\//, '').split('/')) unless $1.nil?  # Add path to page_dir Array
    if extension.nil?
      page_dir << filename
      filename = "index"
    end
    extension ||= new_page_ext
    page_dir = page_dir.map! { |d| d = d.to_url }.join('/')                # Sanitize path
    filename = filename.downcase.to_url

    mkdir_p page_dir
    file = "#{page_dir}/#{filename}.#{extension}"
    if File.exist?(file)
      abort("rake aborted!") if ask("#{file} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
    end
    puts "Creating new page: #{file}"
    open(file, 'w') do |page|
      page.puts "---"
      page.puts "layout: page"
      page.puts "title: \"#{title}\""
      page.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
      page.puts "comments: true"
      post.puts "description: "
      post.puts "keywords: "
      page.puts "sharing: true"
      page.puts "footer: true"
      page.puts "---"
    end
  else
    puts "Syntax error: #{args.filename} contains unsupported characters"
  end
end

Kalau sudah di save.

Buka file octopress-mu/source/_includes/head.html

Cari kode ini:

Rubah jadi seperti ini:

Atau seperti ini juga bisa:

Silakan di pilih mana yang baik.

Kemudian SAVE.

Dan coba buat post baru rake new_post["post-baru"] halaman baru rake new_page[page-baru]

Ketika anda lihat filenya di folder _posts akan terlihat serperti ini:

1
2
3
4
5
6
7
8
9
---
layout: post
title: "Cara Konfigurasi SEO Keywords dan deskripsi Octopress"
date: 2014-09-10 03:49:47 +0700
comments: true
categories: 
description: 
keywords: 
---

Maka isilah kolom description dan keywords jika tidak diisi maka akan menampilkan description dan keywords default yang sudah kita seting sebelumnya di file _config.yml

Kalau gk paham ya ke laut aja, kan bisa komen di bawah ^_^

Happy coding, happy hacking, happy coling. smiley

Comments