SEO itu asset terpenting dalam membangun website, tanya donk kenapa? Nanti akan di jawab dengan rumput yang bergoyang. a.! Ya pokoknya gitu deh…
Tutorial ini akan membuat Rakefile pada ruby anda ketika membuat post menghasilkan teks sepebagi berikut:
123456789
---
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
12345678
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:
12
post.puts "description: "
post.puts "keywords: "
Di taroh dimana ya? Liat contoh dibawah
123456789101112131415161718192021222324252627
# 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
# 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:
123456789
---
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 ^_^