利用翻新文章來拿到更好的 SEO 排名,是個大家都知道但不說的秘密,困難的是有策略性的挑出需要優化文章,本篇文章利用 Google Sheet 定期爬取文章最後更新時間,再搭配 Google Search Console 資料,最後用四分位數排序,有興趣的朋友可試試看~
Table
步驟 1. 建立 Google Sheet
首先我們建立一個新的 Google Sheet,並且在工具列中 “擴充功能” 開啟內建 “Apps Script”:
- 複製下面整段 code,然後在第一行 const sitemaps = ["https://www.maxlist.xyz/post-sitemap.xml"]; 裡面寫入自己的 sitemap 網址
- 在第二行 const sheetName = "工作表1",填入要將資料輸出的位置
- 點擊上方運行
- (option) 如果想要定期運行這段程式,可以在左邊點選觸發條件,並設定定期運行時間
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 |
function main() { const sitemaps = ["https://www.maxlist.xyz/post-sitemap.xml"]; const sheetName = "工作表1" const locRegex = /<loc>(.*?)<\/loc>/g; const lastmodRegex = /<lastmod>(.*?)<\/lastmod>/g; let locMatch, lastmodMatch; const locs = [], lastmods = []; for (let i = 0; i < sitemaps.length; i++) { let response = UrlFetchApp.fetch(sitemaps[i]); let responseText = response.getContentText(); while ((locMatch = locRegex.exec(responseText)) != null) { locs.push(locMatch[1]); } while ((lastmodMatch = lastmodRegex.exec(responseText)) != null) { lastmods.push(new Date(lastmodMatch[1])); } } const sheet = SpreadsheetApp.getActive().getSheetByName(sheetName); sheet.clearContents(); sheet.getRange(1, 1, 1, 3).setValues([["Location", "Last Modified", "Days Since Last Modification"]]); sheet.getRange(2, 1, locs.length, 3).setValues(locs.map(function(loc, index) { const lastmod = lastmods[index]; const daysSinceLastMod = Math.floor((Date.now() - lastmod) / (1000 * 60 * 60 * 24)); return [loc, lastmod, daysSinceLastMod]; })); } |
如果一切順利的話,就會在你的 sheet 裡面看到 Location、Last Modified 和 Days Since Last Modification:
- Location:文章的網址
- Last Modified:文章最後更新的時間
- Days Since Last Modification:文章最後更新時間距離今天過了幾天
步驟 2. 整合 Search Console 資料
拿到每日更新時間後,我們利用 Google Sheet 的第三方套件,匯入 Google Search Console 資料。
當拿到文章的點擊數 (Click)、搜尋排名 (Position) 欄位和距離上次更新時間 (Last Modified) 後,我們利用四分位數將資料給予 1~4 分 (例如:距離上次更新時間越長的文章我們給予 4 分,越接近的 1 分), 最後我們會獲得分數的加總,就可以拿到最需要被優化的文章囉。
其他想法 – 修改 Blog 顯示時間
最後除了優化文章內容的時間外,你也可以留意一下目前 blog 所顯示的時間,像是我使用 sydney 主題,只會顯示發布日期,這時候可以考慮自己修改 wordpress blog 主題,像是我這邊加上如果發佈時間不等於更新時間時,則以更新時間顯示為主。
1 2 3 |
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { $time_string = '<time class="entry-date updated-time" datetime="%3$s" ' . sydney_get_schema( 'modified_date' ) . '> %4$s</time>'; } |
延伸閱讀
- 用四張圖表,理解 Blog 成效
- 5分鐘打造屬於自己的電商儀表板
- 如何利用 Google 商家 進行分析和優化?
- 如何利用公開數據做 Shopee 蝦皮賣家分析
- 如何利用 QSearch Trend 進行 雙 11 社群分析
- 走在數據分析師的路上
- Python 從 0 開始教學手冊
最後 如何更有效率的優化 Blog 舊文章 就到這邊告一個段落,感謝收看,如文章內容有誤請不吝指正!