ブログをリニューアルしました

本サイトの記事には広告が含まれます。

今月に入ってから本ウェブログをリニューアルしました。主な変更点は以下の通りです。

  1. デザインの変更
  2. SSLへの完全移行

ドメイン名の変更はないですので,閲覧側で特に必要なことはありません。http://jiheisyou.org/でブックマークしていても,https://jiheisyou.org/にリダイレクトされます。

強いて挙げるとすれば,apple-touch-iconの変更でしょうか。以下のロゴマークに変更しましたので,iPhoneやiPadでホーム画面などに追加している場合は,キャッシュが更新されない限りは古いロゴのままになってしまう可能性があります。faviconも同様ですね。

画像:apple-touch-icon

トップページはこれまで新着記事のみでしたが,主要カテゴリの人気記事,年齢ごとのタグリンクを設置しました。人気記事はWordPress Popular Postsによる自動集計です。ページビューによる計測ですので,基本的には新しい記事が人気となりやすいですが,検索からの流入の多いハンディカムの記事なんかは常に上位に位置しているようです。

そんなわけで,2度目のリニューアルとなりましたが,今後ともよろしくお願いします。以下はウェブログなどを運営していて興味のある方向けの情報です。

httpからhttpsへのリダイレクト

mod_rewriteモジュールが必要です。以下同様。

.htaccess
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

wwwからwwwなしへのリダイレクト

.htaccess
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

index.htmlを表示しない

WordPressなし

ついでにindex.phpもリダイレクト。

.htaccess
RewriteCond %{THE_REQUEST} ^.*/index.(html|php)
RewriteRule ^(.*)index.(html|php)$ http://%{HTTP_HOST}/$1 [R=301,L]

WordPressあり

# BEGIN WordPress~# END WordPressという行があるはずですので,そこに以下を追記してください。

.htaccess
RewriteRule ^index\.html?$ / [R=301,L]

apple-touch-icon-.*?\.pngへのリクエストが鬱陶しい

以下のように複数回のリクエストがエラーログなどに記録されるのが鬱陶しい場合(ログの肥大化を防ぐ)。

/apple-touch-icon-120×120-precomposed.png
/apple-touch-icon-120×120.png
/apple-touch-icon-precomposed.png
/apple-touch-icon.png

.htaccess
RewriteRule ^apple-touch-icon-.*?\.png$ /apple-touch-icon.png [L]

/apple-touch-icon.pngのみを用意してそちらを返すようにします。

SANGOで記事にサムネイルがない場合に指定の画像をランダム表示

SANGOのカスタマイズに際してはテーマファイルを編集しますので,必ずバックアップをしてから,自己の責任において実行してください。

記事一覧グリッドのカード

sng-function.phpの「記事一覧グリッドのカード」内683行目から(1.8.1の場合)。例えば,本ウェブログでは「お知らせ」のカテゴリはサムネイルが設定されていません。「お知らせ」を再読み込みするとアイキャッチの画像が変わると思います。

修正前
<p class="cardtype__img">
<img src="<?php echo featured_image_src('thumb-520'); ?>" alt="<?php the_title();?>">
</p>
修正後
<?php if (has_post_thumbnail()): ?>
<p class="cardtype__img"><img src="<?php echo featured_image_src('thumb-520'); ?>" alt="<?php the_title();?>"></p>
<?php else: ?>
<?php
$thumb_array = array(
"/path/to/eyecatch-1-520x300.jpg",
"/path/to/eyecatch-2-520x300.jpg",
"/path/to/eyecatch-3-520x300.jpg",
"/path/to/eyecatch-4-520x300.jpg",
);
echo '<p class="cardtype__img"><img src="'.$thumb_array[rand(0, count($thumb_array)-1)].'" alt="'.get_the_title().'" /></p>';
?>
<?php endif;?>

サイドバー最新記事ウィジェット

widget-setting.phpの40行目から(1.8.1の場合)。

修正前
<?php if (has_post_thumbnail()): ?>
<figure class="my-widget__img"><?php the_post_thumbnail('thumb-160');?></figure>
<?php endif;?>
修正後
<?php if (has_post_thumbnail()): ?>
<figure class="my-widget__img"><?php the_post_thumbnail('thumb-160');?></figure>
<?php else: ?>
<?php
$thumb_array = array(
"/path/to/eyecatch-1-160x160.jpg",
"/path/to/eyecatch-2-160x160.jpg",
"/path/to/eyecatch-3-160x160.jpg",
"/path/to/eyecatch-4-160x160.jpg",
);
echo '<figure class="my-widget__img"><img src="'.$thumb_array[rand(0, count($thumb_array)-1)].'" alt="" /></figure>';
?>
<?php endif;?>

サイドバー人気記事ウィジェット

widget-setting.phpの163行目から(1.8.1の場合)。

修正前
<?php if (get_the_post_thumbnail($post->ID)): ?>
<figure class="my-widget__img"><?php echo get_the_post_thumbnail($post->ID, 'thumb-160'); ?></figure>
<?php endif;?>
修正後
<?php if (get_the_post_thumbnail($post->ID)): ?>
<figure class="my-widget__img"><?php echo get_the_post_thumbnail($post->ID, 'thumb-160'); ?></figure>
<?php else: ?>
<?php
$thumb_array = array(
"/path/to/eyecatch-1-160x160.jpg",
"/path/to/eyecatch-2-160x160.jpg",
"/path/to/eyecatch-3-160x160.jpg",
"/path/to/eyecatch-4-160x160.jpg",
);
echo '<figure class="my-widget__img"><img src="'.$thumb_array[rand(0, count($thumb_array)-1)].'" alt="" /></figure>';
?>
<?php endif;?>

「お知らせ」の人気記事

この記事も読まれています!