Linux 软件免费装
Banner图

Simple hreflang

开发者 hfranz
更新时间 2026年12月4日 18:51
PHP版本: 7.4 及以上
WordPress版本: 7.2
版权: GPL-2.0-or-later
版权网址: 版权信息

标签

seo navigation multilingual alternate hreflang

下载

1.6.0 1.4.0 1.3.0 1.2.0 1.5.0

详情介绍:

Simple hreflang makes your multilingual WordPress website ready for international search engines. The plugin clearly identifies your language versions, helping search engines understand which pages belong together. This makes it easier for visitors to find the right language version, providing a better user experience and improving your international search visibility. How it works For each page, post, and category, you enter its alternate-language versions — as many as you need, each as an hreflang code and URL (e.g. en-US and https://example.com/en/about/). Simple hreflang then outputs them as <link rel="alternate" hreflang="…"> tags in the <head> of that page, including the self-referencing link to the page itself that Google recommends. Custom post types and other taxonomies can be enabled with a filter. Features Why no block for the hreflang tags themselves? hreflang annotations are only evaluated by search engines in the <head> (or via HTTP header or sitemap), not in the visible page content. A block inserted into the content would end up in the <body> and simply be ignored. That's why this plugin deliberately uses post/term meta for the hreflang data itself, instead of a block. Language Link block for the Navigation block Your visitors benefit from the same data: for block themes, the plugin adds a "hreflang Language Link" block that can be inserted inside the Navigation block. Set the target language (e.g. en-US) and the block links to the current page's hreflang alternate for that language. Optionally, give it a custom label (e.g. "English" instead of en-US), an icon, and a tooltip. If the current page has no matching alternate, the menu item is left out of the navigation entirely — not just hidden. Multisite The plugin is fully multisite-compatible. It can be network-activated (active on every site) or activated per site individually, whichever fits your setup — each site keeps its own hreflang data, since post/term meta is already scoped per site.

安装:

  1. Upload the sev-simple-hreflang folder to the /wp-content/plugins/ directory.
  2. Activate the plugin through the "Plugins" menu in WordPress.
  3. When editing a page/post: open the sidebar, expand the "hreflang (alternate language versions)" panel. For categories: the field is directly in the form. For post types using the classic editor: the field is in a meta box below the content.

屏幕截图:

  • The "hreflang Language Link" block in the block inserter, ready to be added to the Navigation block.

常见问题:

Why don't I see a block for hreflang tags in the editor?

There deliberately isn't one. hreflang tags must live in <head>, not in the content — a content block would be ignored by search engines.

Can I add a language switcher to my navigation menu?

Yes, if your theme is a block theme. Add the "hreflang Language Link" block inside the Navigation block, set the target hreflang code, and it links to the current page's matching alternate. A language code like en links to any English version (en-US, en-GB, …), a full code like en-US only to that one; an exact match always wins. Pages without a matching alternate simply don't show that menu item.

Do I have to enter the alternates on every language version?

Yes. Search engines only trust hreflang annotations that are confirmed in both directions: if your German page points to the English page, the English page must also point back to the German one. Simple hreflang does not add these return links automatically, so enter the alternates on each language version of the page.

Which content types are supported?

Out of the box: pages, posts, and categories, including a static front page and the static "Posts page". A front page showing your latest posts is not supported. Custom post types and other taxonomies can be enabled with two filters, e.g. in your theme's functions.php: add_filter( 'sev_simple_hreflang_post_types', fn( $types ) => array_merge( $types, array( 'product' ) ) ); add_filter( 'sev_simple_hreflang_taxonomies', fn( $taxonomies ) => array_merge( $taxonomies, array( 'post_tag', 'product_cat' ) ) ); Post types edited in the block editor get the sidebar panel, post types using the classic editor (such as WooCommerce products) get a meta box below the content.

Which hreflang codes are valid?

A language code according to ISO 639-1 (en), optionally followed by a country code according to ISO 3166-1 alpha-2 (en-GB) and/or a script according to ISO 15924 (zh-Hant, zh-Hant-TW), or x-default. The editor warns you about invalid codes such as en-UK (the correct code is en-GB) or english; these entries are saved but not output. Different spellings such as en_us are corrected to en-US automatically.

Where does the language of the self-referencing link come from?

From the site language in Settings > General (e.g. de-DE). Variants like "Deutsch (Sie)" (de-DE-formal) are output as the plain language code (de-DE). The code can't be changed in the plugin, so if you need a different one for the current site (e.g. de-AT), adjust the site language accordingly. The self-referencing link is only output on pages that have at least one alternate; on its own, it would carry no information.

Does this work with WPML/Polylang?

The plugin works independently of multilingual plugins and manages hreflang values manually per page/post/category. If WPML or Polylang is active and already outputs hreflang, you may end up with duplicate tags — in that case, please use only one of the two solutions.

Is x-default supported?

Yes — just enter x-default as the hreflang code.

Does this work on Multisite?

Yes. The plugin can be network-activated or activated per site; each site manages its own hreflang data independently.

What happens to my data when I delete the plugin?

Deactivating the plugin keeps your hreflang data, so nothing is lost if you reactivate it. Deleting the plugin removes all hreflang data it stored for pages, posts, and categories — on a multisite network, on every site. No other data is touched.

更新日志:

1.6.0 1.5.0 1.4.0 1.3.0 1.2.0 1.1.0 1.0.0