MENU
World's First International Island Manga "まはらじま(MAHARAJIMA)" Official Website | Tourism & Lifestyle Data for 500 Islands and Island Nations

Automated Multilingual Tagging for International SEO

多言語タグの共通自動実装
SUWANOSEJIMA

🇯🇵 Int'l Island Manga Artist, Ira
🇸🇬 Singapore PR
🌏 ADHD + ASD | IQ 115 | BMI 17.7
⛴️ Fastest to 500 islands in 3 years (World Record)
🙇 Japanese-to-English Google Translation. Apologies for any errors.

Table of Contents

One of the Essential Tasks When Running Multiple Language Sites Across Multiple Domains

花<br>HANA

When I asked Gemini to generate the code, it included unnecessary comments in the code.
Example) “SEO Basics” etc. The following is correct, but please be careful even with Gemini Pro (Summer 2026).
If you show a screenshot of your screen to the AI, it will create something tailored to your site.

💻 Summary of Task Outline, Purpose, and SEO Effects

ItemContent
Task OutlineAutomated insertion of hreflang tags (language alternate tags) into the <head> section using functions.php.
Primary PurposeExplicitly signaling the paired relationship between the English site (parent) and the Japanese site (child) sharing identical content to search engines.
SEO Effects• Avoid penalty risks caused by duplicate content issues.
• Accurately display the appropriate language page (English/Japanese) in search results based on the user’s language settings.
• Prevent the dilution of page authority for each language and optimize search engine indexing.

💻 Purpose and Overview of the Task

To ensure Google correctly recognizes your pages as distinct languages, the tag pointing from “A (English) to B (Japanese)” and the tag pointing from “B (Japanese) to A (English)” must be set up as a pair (bi-directional).

If the tag exists on only one of the sites, Google will treat it as an error and invalidate it.

Therefore, you must paste the exact same code into the respective functions.php files of both domains (on both WordPress installations).

💻 Code to Paste into functions.php for Universal Automation of hreflang (Multilingual) Tags

function add_custom_hreflang_tags() {
if ( is_404() || is_search() ) {
return;
}

$parsed_url = wp_parse_url( $_SERVER['REQUEST_URI'] );
$path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : '/';

$en_url = 'https://example.com' . $path;
$ja_url = 'https://jp.example.com' . $path;

echo '<link rel="alternate" hreflang="en" href="' . esc_url($en_url) . '" />' . "\n";
echo '<link rel="alternate" hreflang="ja" href="' . esc_url($ja_url) . '" />' . "\n";
echo '<link rel="alternate" hreflang="x-default" href="' . esc_url($en_url) . '" />' . "\n";

}
add_action(‘wp_head’, ‘add_custom_hreflang_tags’);


Why Bi-directional hreflang Tags Matter

To ensure Google recognizes your multilingual content correctly, hreflang tags must be bi-directional. The English page must link to the Japanese page, and the Japanese page must link back to the English page. One-way tagging triggers validation errors and gets ignored by search engines.

Key Benefits

  • Zero Duplicate Penalties: Eliminates search engine penalties for identical content across regions.
  • Accurate Targeting: Automatically serves the correct language version based on user location and settings.
  • Link Equity Retention: Consolidates ranking signals and authority across all language variants.

7-Step Implementation Guide for SWELL Theme (WordPress)

Instead of manual tagging, you can automate this across both domains by injecting a dynamic program into functions.php.

  1. Activate Child Theme: Go to Appearance > Themes and ensure SWELL CHILD is active. Never edit the parent theme directly.
  2. Open Code Editor: Navigate to Appearance > Theme File Editor.
  3. Select SWELL Child: Choose SWELL CHILD from the dropdown in the top-right corner and click Select.
  4. Open Functions File: Click functions.php from the file list on the right.
  5. Insert Code: Paste your automated PHP script at the very bottom of the editor.
  6. Save: Click Update File and ensure the success message appears.
  7. Verify: Visit any live post, view the page source (Ctrl+U or Cmd+Option+U), and verify that the three hreflang tags are active in the <head> section.

Ira(アイラ): World record holder for exploring over 500 islands in just about 3 years.
As an island manga artist, Ira serves as a valuable social example of leveraging ADHD and ASD traits to their fullest.
Author of the international island manga MAHARAJIMA(まはらじま).
Holds Singapore Permanent Residency (PR) and a Master’s degree in Intellectual Property.
[Link to Profile & Achievements]
[YouTube Channels: 1. Islands & Unexplored Regions | 2. Singapore & Mountains]

TAKARAJIMA

💻 Server migration in July 2026.
🚧 Major website maintenance will continue until early August.

🌏✈️ Living Abroad | 500+ Islands 🏝️ 📍 Regional Guides (Packed with hidden gems!)

SG All Genres Top Page (Island List is here)

1.gourmet:Home-cooked meals/Eating out/Hospital cafeteria🍽️

2.Sightseeing/Souvenirs/Culture/Accommodations⛲️🏝️🚴‍♀️🛏️💰

3.living:Real estate/Medical care/School/Work/Crime, etc.🏠🏥

4.interaction:Romance/Marriage/Divorce/Friends🤵‍♀️

5.interaction:Romance/Marriage/Divorce/Friends🤵‍♀️
Singapore/Malaysian relatives:🧑‍🦳✏️💰

6.etc💁‍♂️

多言語タグの共通自動実装

この記事が気に入ったら
フォローしてね!

Table of Contents