Cara Mengubah Format Permalink Blogger Menjadi Seperti URL Wordpress

Cara merubah permalink postingan Blogger menjadi seperti permalink wordpress agar SEO di Mesin Pencarian Google.
Cara Mengubah Permalink Blogger Menjadi Seperti Wordpress

Mengubah Permalink Blogger/Blogspot Seperti URL WordPress - Terdapat perbedaan permalink antara kedua platform yang satu ini, terutama pada permalink postingan ataupun halaman blog. Dimana blog yang dibuat menggunakan Blogger memiliki permalink atau URL dengan format tahun, bulan dan diakhir terdapat eksitensi .html.

Sedangkan wordpress memiliki permalink yang hanya berisikan teks tanpa format lain, itu karena wordpress memiliki fitur custom permalink yang bisa dirubah sesuai format permalink yang di inginkan. Berbeda dengan Blogger yang belum terdapat opsi custom permalink yang disediakan.

Permalink yang hanya berisi teks dengan format seperti wordPress lebih simpel dan enak dilihat ketimbang permalink yang panjang dengan penambahan format tahun dan bulan. Lalu apakah bisa menghilangkan format tahun dan bulan pada url blogger?

Table of Contents

Mengubah Format Permalink Blogger Seperti Permalink WordPress

Meski blogger tidak memiliki opsi custom permailink tapi kamu masih bisa merubah permalink Blogger menjadi seperti permalink wordpress, yaitu dengan cara menggunakan pengalihan url menggunakan javascript.

Pengertian Permalink

Permalink atau Permamen Link biasa disebut URL singkatan dari Uniform Resource Locator merupakan alamat postingan sebuah dari sebuah website atau yang mengarah pada sebuah halaman, file yang sering kamu jumpai di internet.

Sebagai contoh Permalink/URL yang disediakan oleh Blogger memiliki format domain(dot)com/YYYY/MM/judul-postingan.html Sedangkan Permalink Permalink/URL wordpress sebagai berikut domain(dot)com/judul-postingan

Contoh Permalink Blogger dan Wordpress

Blogger

https://www.inputekno.com/2020/09/cara-membuat-maintenance-mode-blogger.html

Wordpress

https://www.inputekno.com/cara-membuat-maintenance-mode-blogger


Cara Mengubah Permalink/URL Blogger seperti Permalink WordPress

Sebelum mengikuti tutorial ini, ada baiknya Backup terlebih dahulu template Blogger kamu untuk berjaga-jaga jika terjadi error. Jika sudah berikut tutorial nya :

Cara Mengubah Permalink Blogger Menjadi Seperti Wordpress Cara Mengubah Permalink Blogger Menjadi Seperti Wordpress 2 Cara Mengubah Permalink Blogger Menjadi Seperti Wordpress 3
Langkah #1 : Buka dashboard Akun Blogger kamu
Langkah #2 : Pergi ke Tema > Edit HTML
Langkah #3 : Lalu cari kode pembuka <head> kemudian Copy kode dibawah ini tepat dibawah kode <head> tersebut.
<script type='text/javascript'>
//<![CDATA[
// BloggerJS v0.4.0
// Licensed under the MIT License
// Copyright (c) 2017-2018 Kenny Cruz
// github.com/jokenox

// Setting
var config = {
// Allow dates in ticket URLs.
  postsDatePrefix: false,

// short URL just to enter the site,
// but not in its general operation.
  accessOnly: false,

  // Usar API v3 de Blogger.
  useApiV3: false,
  apiKey: "BLOGGER-API-V3"
}

var postsOrPages = ["pages", "posts"],
    blogId = "<data:blog.blogId/>",
    urlTotal, fetchIndex = 1,
    ampChar = "&amp;"[0],
    secondRequest = true,
    feedPriority = 0,
    nextPageToken;

// urlVal ();
// Validate if the URL corresponds to a post / page, 
// if not, or if it corresponds to the index.
function urlVal() {
  var url = window.location.pathname;
  var length = url.length;
  var urlEnd = url.substring(length - 5);
  if (urlEnd === ".html") return 0;
  else if (length > 1) return 1;
  else return 2;
}

// urlMod (); 
// Modify the URL by removing the date or the "/ p /" as well as the ".html".
function urlMod() {
  var url = window.location.pathname;
  if (url.substring(1, 2) === "p") {
    url = url.substring(url.indexOf("/",1) + 1);
    url = url.substr(0, url.indexOf(".html"));
    history.replaceState(null, null, "../" + url);
  } else {
    if (!config.postsDatePrefix) url = url.substring(url.indexOf("/",7) + 1);
    else url = url.substring(1);
    url = url.substr(0, url.indexOf(".html"));
    history.replaceState(null, null, "../../" + url);
  }
}

// urlSearch (url, database);
// Look for a specific url in the database, if found,
// then it will direct to her.
function urlSearch(url, database) {
  var pathname = url + ".html";
  database.forEach(function(element) {
    var search = element.search(pathname);
    if (search !== -1) window.location = element;
  });
}

// urlManager (database, id);
// Run a URL validation, to determine with the result
// the action to perform (modify it or find it in the blog feed).
function urlManager() {
  var validation = urlVal();
  if (validation === 0) {
    if (!config.accessOnly) urlMod();
  } else if (validation === 1) {
    fetchData(postsOrPages[feedPriority], 1);
  } else if (validation === 2) {
    if (!config.accessOnly) history.replaceState(null, null, "/");
  }
}

// fetchData ();
// Make a request for blog data.
function fetchData(postsOrPages, index) {
  var script = document.createElement("script");
  if (config.useApiV3) {
    var jsonUrl = "https://www.googleapis.com/blogger/v3/blogs/" + blogId + "/" + postsOrPages +
                  "?key=" + config.apiKey + "#maxResults=500#fields=nextPageToken%2Citems(url)#callback=parseData";
    if (nextPageToken) jsonUrl += "#pageToken=" + nextPageToken;
    nextPageToken = undefined;
  } else {
    var jsonUrl = window.location.protocol + "//" + window.location.hostname + "/feeds/" + postsOrPages +
                  "/summary?start-index=" + index + "#max-results=150#orderby=published#alt=json-in-script#callback=parseData";
  }
  jsonUrl = jsonUrl.replace(/#/g, ampChar);
  script.type = "text/javascript";
  script.src = jsonUrl;
  document.getElementsByTagName("head")[0].appendChild(script);
}

// parseData ();
// Get data in JSON format, classify it
// and send them to compare the current URL.
function parseData(json) {
  var database = [];

  if (!config.useApiV3) {
    if (!urlTotal) {
      urlTotal = parseInt(json.feed.openSearch$totalResults.$t);
    }

    try {
      json.feed.entry.forEach(function(element, index) {
        var entry = json.feed.entry[index];
        entry.link.forEach(function(element, index) {
          if (entry.link[index].rel === "alternate") database.push(entry.link[index].href);
        });
      });
    } catch(e) {}
  } else {
    try {
      json.items.forEach(function(element, index) {
        database.push(element.url);
      });
    } catch(e) {}
    nextPageToken = json.nextPageToken;
  }

  urlSearch(window.location.pathname, database);

  if (urlTotal > 150) {
    fetchIndex += 150;
    urlTotal -= 150;
    fetchData(postsOrPages[feedPriority], fetchIndex);
  } else if (nextPageToken) {
    fetchData(postsOrPages[feedPriority]);
  } else if(secondRequest) {
    nextPageToken = undefined;
    urlTotal = 0;
    fetchIndex = 1;
    secondRequest = false;
    if (feedPriority === 0) {
      feedPriority = 1;
      fetchData("posts", 1);
    } else if(feedPriority === 1) {
      feedPriority = 0;
      fetchData("pages", 1);
    }
  }
}

// bloggerJS ();
// Start BloggerJS.
// You can receive as a parameter the search order for the URLs,
// that is, if it will start to compare against pages or posts.
// 0 or empty = Pages, 1 = Entries.
function bloggerJS(priority) {
  if (priority) feedPriority = priority;
  urlManager();
}

bloggerJS();
//]]>
</script>
Contoh penempatan seperti kode dibawah. Kemudian Save Template jika sudah.
<head>
<!-- Paste Code Disini -->
...
Scrip diatas adalah untuk menghapus format postingan blogger /YYYY/MM dan halaman /p/ serta eksitensi .html diakhir postingan. Jadi jika dibuka nantinya ini akan terlihat seperti permalink wordpress.

Tutorial ini saya dapatkan dari akun Jokenox di github, untuk dokumentasi lengkapnya kamu bisa cek langsung di github.


Penutup

Itu tadi cara mengubah permalink Postingan Blogger menjadi seperti permalink WordPress, semoga artikel ini bermanfaat dan membantu.

Perlu diperhatikan juga, menurut beberapa artikel yang saya baca, menghapus format permalink blogger untuk blog yang sudah cukup lama atau memiliki artikel yang sudah terindeks di Google akan menurunkan kualitas SEO, jadi ada baiknya tutorial ini hanya digunakan untuk Blog yang masih baru atau belum memiliki beberapa artikel yang terindeks.
Hi. Lets connect and be friends!
Gabung dalam percakapan