ã¯ãŠãªããã°ããã¬ã³ã¿ã«ãµãŒããžãšç§»è»¢ããéã«ãç¡æã®ã¯ãŠãªã¢ã«ãŠã³ãã§ã¯ãcanonicalã®å€æŽã301ãªãã€ã¬ã¯ããè¡ããŸãããããããããã§ãJavaScriptã§èšå®ãããã°ãGoogleã移転ãç解ããŠãããããšãåãã£ãŠããŸãããã®ããŒãžã§ã¯ãæ°URLãžã®ãªãã€ã¬ã¯ããšcanonicalã®èšå®ãããæ¹æ³ã玹ä»ããŸãã
ãªããæçš¿ããŒã¿ã®ç§»è»¢æ¹æ³ã«ã€ããŠã¯ããã¡ãã®èšäºã§çŽ¹ä»ããŠããŸãã®ã§ãããã£ããåèã«ããŠã¿ãŠãã ããã
ã¯ãŠãªããã°ãããã¬ã³ã¿ã«ãµãŒã + WordPressãµã€ããžã®ç§»è»¢æ¹æ³
Googleã¯ããŒã©ã¯ãç°¡åãªJavaScriptãªãç解ããŠãããŸãã
æ¬æ¥ããµã€ãã®ç§»è»¢ã«ã¯ãSearch consoleã®ãã«ãã§ã°ãŒã°ã«ãæžããŠããããã«ã301ãªãã€ã¬ã¯ãã䜿ã£ã移転ãçæ³çã§ãã
ããããã¯ãŠãªããã°ã§ã¯å€éšãžã¯301ãªãã€ã¬ã¯ããèšå®ã§ããªãããããã®ç°å¢äžã§æåã®æ¹æ³ãšããŠãJavaScriptãçšãã移転æ¹æ³ã玹ä»ããŸãã
æ¬æ¹æ³ã«ããããã®ããã°ã¯ç¡äºã«Googleã®ã€ã³ããã¯ã¹ã移転ããããšã«æåããŠããŸãã
ãã®JavaScriptã§ã¯æ¬¡ã®ããšãè¡ããŸãã
- èšäºäžã§ã®ã移転ããŸããã衚瀺ãšãªã³ã¯ã®è²Œãä»ã
- æ°ç§åŸ ã£ãŠããããªãã€ã¬ã¯ã
- ã¯ãŠãªãæ¢ã«èšå®ããŠããŸã£ãŠãã canonical ã¿ã°æžãæã
canonical(æ£èŠå)ã¿ã°ãšã¯ãWebããŒãžãéè€ããŠããéã«ãã©ã®ããŒãžãgoogleã«ã€ã³ããã¯ã¹ããŠã»ããã瀺ãã¿ã°ã§ããããã¯ãæ°ãµã€ããã³ããŒãµã€ãã§ã¯ãªãããšã瀺ãã®ã«æå¹ã§ãã
ç®æ¬¡
èšå®æ¹æ³
ã¯ãŠãªããã°ã®ãã¶ã€ã³èšå®ãããèšäºããŒãžã«äžæ¬ããŠJavaScriptã貌ãããšãåºæ¥ãŸãã
èšå®å Žæ
次ã®å Žæã«ãåŸè¿°ãããœãŒã¹ã³ãŒãã貌ãä»ããŸãã
ã¯ãŠãªããã° > ããã·ã¥ããŒã > ãã¶ã€ã³ > ã¬ã³ãã®ããŒã¯ > èšäº > èšäºäžäžã®ã«ã¹ã¿ãã€ãº > èšäºäž
ãŸãã¹ããŒããã©ã³çšããŒãžã®èšå®ãšããŠã次ã«ãã§ãã¯ããããŸãã
ã¯ãŠãªããã° > ããã·ã¥ããŒã > ãã¶ã€ã³ > ã¹ããŒããã©ã³ã®ã¢ã€ã³ã³ > èšäº > èšäºäžäžã®ã«ã¹ã¿ãã€ãº > PCãšåãhtmlã衚瀺ãã
ã³ãŒã
ãã®æ å ã«ã次ã®ã³ãŒãã貌ãä»ããŸãã
<p>移転ããŸããã
<script type="text/javascript" language="javascript">
<!--
// æ°urlã®äœæ
ããvar domain = "https://beiznotes.org/";ã// æ°ãã¡ã€ã³ + ãã£ã¬ã¯ããªã«çœ®ãæãããæ«å°Ÿã¯ã¹ã©ãã·ã¥ã
ããvar path = location.pathname.substr(6).replace(/\//g, "") + "-2"; // ãã¹ã®æŽåœ¢
ããvar url = domain + path;
// ãªã³ã¯htmlã®æžãåºã
ããdocument.write("<a href=\"" + url + "\">" + url + "</a></p>");
// ãªãã€ã¬ã¯ã
ããsetTimeout("redirect()", 5000);ã// 5 sec
ããfunction redirect(){
ãã ãlocation.href = url;
ãã}
ã
ã// canonical ã®æžãæã
ããvar link = document.getElementsByTagName("link")[0];
ããlink.href = url;
-->
</script>
ã³ãŒãã®èª¬æ
æ°URLã®äœæ
“æ°URLã®äœæ”ã®éšåã§ã移転å ã®URLãæºåããŠããŸãããã®ã³ãŒãã§ã¯ããªãã€ã¬ã¯ãå ãšå ã®URLã次ã®éãã§ãããšä»®å®ããŠããŸãã
- ã¯ãŠãªããã°ã®URL: hatena-domain/entry/2016/11/15/012345
- 移転å URL: new-domain/20161115012345-2
ããã¯ãã¯ãŠãªããã°ã§ãšã¯ã¹ããŒãããŠãWordpressã«ã€ã³ããŒããããšãã®æšæºçãªãã®ã§ããèšäºURLã«ç¹å¥ãªèšå®ãããŠããªãå Žåã¯ãããã§ãããŸãããªããéå»ã«ã¯ãŠãªãã€ã€ãªãŒãããã¯ãŠãªããã°ã«èšäºãã€ã³ããŒãããŠããå Žåã¯ãã¹ããhatena-domain/entry/20161115/012345ãšãªã£ãŠããŸããããã®å ŽåãåããŸãã
ã³ãŒãäžã®æ°ãã¡ã€ã³ã®éšåã¯ãèªèº«ã®ç§»è»¢å ã®URLãæå®ããŸããããåŸãã«ãã£ã¬ã¯ããªãå ¥ã£ãŠãããã§ãã
“ãã¹ã®æŽåœ¢”ãšã³ã¡ã³ãããŠããè¡ã®èª¬æãããŸãã
- location.pathnameã§çŸåšã®(ã¯ãŠãªããã°ã®)ãã¹ãååŸããŸãã
- substr(6)ã§ãæ§ãã¹äžã®”entry”ã®æååãæ¶ããŸããsubstr(n)ã¯ãnæåç®ä»¥éãåãåºãé¢æ°ã§ãã
- replace()ã§ã¹ã©ãã·ã¥ãåãé€ããŸãã第äžåŒæ°ã«ã”/æ¶ãããæå/g”ãšå ¥ããŸããä»åã¯ã¹ã©ãã·ã¥ã眮ãæããŸãã®ã§ã\ã§ãšã¹ã±ãŒãããŠã”/\//g”ãšãªã£ãŠããŸãã
- +æŒç®åã§æ«å°Ÿã«”-2″ãè¿œå ããŸããWordpressã§URLã«-2ãã€ããŠããŸãçç±ã«ã€ããŠã¯ããã¡ãã®èšäºãåç §ããŠãã ããã
ãªã³ã¯htmlã®æžãåºã
ãã®éšåã§ã¯ãäœæããurlã䜿ãã<a href=””>ã¿ã°ãæ¿å ¥ããŸãã”+”ããæååãçµåããæŒç®åã§ããhtmlãå€æŽãããå Žåã¯ãããé©å®å€æŽããŠãã ããããªãåé ã®ã移転ããŸããããã®æååãé©å®å€æŽããŠãã ããã
ãªãã€ã¬ã¯ã
5000ããªç§åŸã«ãªãã€ã¬ã¯ããããèšå®ãããŠãããŸãããªãã€ã¬ã¯ãããªãå Žåã¯ããã®éšåã¯åé€ããŠãã ããããªã³ã¯ããŠãŒã¶ãèžãæéãªãã«ãŠãŒã¶ã移åãããããŸãããå ã®ããŒãžã«æ»ããããšãã人ã匷å¶çã«é£ã°ãããŠããŸãã®ã§ãäžé·äžçãããããŸããã
canonicalã®æžãæã
ã¯ãŠãªããã°ã§ãœãŒã¹ã³ãŒãã®è¡šç€ºããããšããããŸãããheadéšã§è©²åœã®èšäºèªèº«ã®URLãž canonical ã¿ã°ã®èšå®ããããŠããŸããäŸãã°æ¬¡ã®ãããªæãã§ãã
<link rel="canonical" href="http://beiz23.hatenablog.jp/entry/20141016/1413385892"/>
ããã®hrefèŠçŽ ã®äžèº«ããæ°urlãžãšçœ®ãæããŸããå®éã®åŠçã§ã¯ãäžçªåãã®linkã¿ã°ã«å¯ŸããŠçœ®ãæãããããªã£ãŠããŸããcanonicalã¿ã°ã¯ãheadéšã®æ©ãéšåã§èšè¿°ããããšãæšå¥šãããŠãããã¯ãŠãªããã°ããã®ããã«ãªã£ãŠããŸãã®ã§ãäžçªç®ã®linkã¿ã°ãæžãæãããšããŸãããããšããããã§ãã
Search Consoleã§ã移転ãGoogleã«ç¥ããã
以äžã®ããã«ããŒãžã«ãªãã€ã¬ã¯ããèšå®ãããšããŠããGoogleããªãã€ã¬ã¯ããç¥ãã®ã¯æ¬¡ã®ã¯ããŒã«ã®ãšãã§ããã¯ããŒã«é »åºŠãäœãããŒãžã§ã¯æ°ã¶æããã£ãŠããŸããŸãããã®ãããSearch Consoleã§ã¯ããŒã«èŠæ±ãããŸãããã
- æ§ãµã€ãã®Search Consoleããããã¯ããŒã« > Fetch as Googleããéžã³ãŸãã
- ãªãã€ã¬ã¯ããèšå®ããããŒãžã®urlãå ¥åããååŸããã¿ã³ãæŒããŸãã
- ãããšæ¬¡ã®ããã«è¡šç€ºãããŸãã
- ã¹ããŒã¿ã¹ãããªãã€ã¬ã¯ããããŸãããã«ãªã£ãŠããããšã確èªããŠãã ããã
- ãã€ã³ããã¯ã¹ç»é²ããªã¯ãšã¹ãããã¿ã³ãæŒããŠå®äºã§ãã
ãŸãšã
ãã®æ¹æ³ã§ã¯ã301ãªãã€ã¬ã¯ãã®ããã«ãã£ã¡ã移転ã§ããããã§ã¯ãããŸããããããçšåºŠããŒãžã©ã³ã¯ã®äžãã£ãæ§ãµã€ãã®äžã€äžã€ã®èšäºãããæ°ããã°ã«ãªã³ã¯ããªãããŸãããã®ããããŠãŒã¶ãšããŠã¯æ°ããèŠãããæ°ãµã€ãã§èšäºãèªãããšãã§ããŸãããèè åŽãšããŠãæ°ãµã€ããžã®PVæ°ã®ç§»è¡ã«å¹æçã ãšæãããŸããã³ãŒããã²ãšã€è²Œãä»ããã ãã§åºæ¥ãŠããŸãã®ã§ããã²ãã©ã€ããŠã¿ãŠãã ããã
次ã®æ¬ã¯ãWordpressãå°å ¥ããéã«åœ¹ç«ã€ããããã®æ¬ã§ãã
- ç³å·æ å (è), 倧䞲 è (è), æééŠæ (è)
- ã€ã³ãã¬ã¹
- äŸ¡æ Œï¿¥1,548(2024/09/10 15:34æç¹)
- Amazonã§å£ã³ãã»ã¬ãã¥ãŒãèŠã
- å®è€ ç¯€å² (è), å²¡æ¬ ç§é« (è), å€è³ 海人 (è), 深沢 幞治é (è)
- æè¡è©è«ç€Ÿ
- äŸ¡æ Œï¿¥2,539(2024/09/10 15:34æç¹)
- Amazonã§å£ã³ãã»ã¬ãã¥ãŒãèŠã
ãã³ããã¯: ã¯ãŠãªããã°ãããã¬ã³ã¿ã«ãµãŒã + Wordpressãµã€ããžã®ç§»è»¢æ¹æ³
ã¯ãŠãªããã°ãããµã€ã移転æã«åèã«ãããŠããã ããŸããã
ãµã€ã移転æã«åèã«ãããŠããã ããŸããã
ããããJavaScriptã§ç§»è»¢èšå®ããŠãªãã€ã¬ã¯ããããããšã確èªããŸããããFetch as Googleã§ããªãã€ã¬ã¯ããããŸããããšè¡šç€ºãããŸããã
ãã®ãŸãŸã§ãåé¡ãªãã®ã§ããããã
Fetch as Googleã§ããªãã€ã¬ã¯ããããŸããããšè¡šç€ºãããããšãçæ³ã§ãããã ãèšå®ããŠããã ãšãªãã€ã¬ã¯ããèªèãããªãå Žåãããããã§ããæéã眮ããŠããå床Fetch as GoogleããŠã¿ãŠãã ãããã
ãªãã€ã¬ã¯ãèšå®ãããåŸã«ãã¯ãŠãªããã°ãéå ¬éèšå®ã«ããã®ã§ãããã®å Žåãå¹æããããŸããïŒ
ã¯ãŠãªããã°ãéå ¬éèšå®ã«ãããšããªãã€ã¬ã¯ãèšå®éšåãgoogleããŠãŒã¶ãŒãèªã¿èŸŒãããšãã§ããŸããã®ã§ãå¹æã¯ãªããªããšæããŸããããããã§ããããã
ã¯ãŠãªããã°ããWordPressãžç§»è¡ããŸããããã®éããã¡ã€ã³å€æŽãåæã«å®æœããã®ã§ããã®èšäºã«èšèŒã®javascript ã®å¯Ÿå¿ãå®æœããŠããŸããã䌺ããããã®ã¯ããã®åã®è³ªåãšéè€ããŸãããã¯ãŠãªããã°ã®èšäºãåãäžããåŠçãããæ¹ãããã®ãïŒåœåã®éã¯ãã®ãŸãŸæŸçœ®ããŠãããŠããã®ãã«ã€ãè¿·ã£ãŠããŸãã
ã¢ããã€ã¹ãé¡ãã§ããŸãã§ããããïŒ
ã¯ãŠãªããã°ã§èšäºãæ¶ãã¹ããã©ãããšããäºã§ããããªãã€ã¬ã¯ãã®èšå®ãããŠããã°ãã©ã¡ãã§ãå·®ã¯ãªããšæããŠããŸãã
èšäºãæ¶ãã®ã¯æéã ãšæããŸãã®ã§ãç§ãªããã®ãŸãŸã«ããŠãããŸãã3ãã6ã¶æãããããŠã¢ã¯ã»ã¹æ°ãæžã£ããããã°ããšæ¶ããŠãè¯ãã§ãããã
æ©éã®ãåçããããšãããããŸããåºæ¥ããåœåã®éã¯åé€ããããªãã£ãã®ã§ãã¢ã¯ã»ã¹æ°ããªããªããŸã§ãã®ãŸãŸã«ããŠããããšæããŸããããããšãããããŸããã