Urgent.News

What's breaking now, across thousands of outlets.

Tech

Multilingual Ghost CMS Blog: 7. Adding hreflang

The English home is served at / , and the Korean home at /ko/ , but search engines had no information indicating that the two pages were versions in different languages. Providing users with a Language selector and explaining multilingual relationships to search engines are separate issues. For search engines, you need to use hreflang to indicate the relationship between each language URL. In…

Multilingual Ghost CMS blog: Adding hreflang links

The English and Korean versions of this blog have different URLs: https://sanghunkang.com/ for English and https://sanghunkang.com/ko/ for Korean. However, search engines had no way of knowing that these pages were language-specific. The solution is to use the hreflang attribute to indicate the relationship between each language URL.

In the 0.0.7 release, hreflang was added to the English and Korean home pages. The home page URLs are:

- English: https://sanghunkang.com/

- Korean: https://sanghunkang.com/ko/

To add the hreflang attribute to both pages, I included three links in the <head> section of each page:

```html

<link rel="alternate" hreflang="en" href="https://sanghunkang.com/">

<link rel="alternate" hreflang="ko" href="https://sanghunkang.com/ko/">

<link rel="alternate" hreflang="x-default" href="https://sanghunkang.com/">

```

The "x-default" language indicates the default page to use when the user's language is not clearly matched.

At first, I attempted to check if the current page was the home page using the `{{#is home}}` condition in default.hbs, but Ghost treats `/ko/` as the site home because it's the first page of a Collection created with routes.yaml. This caused the hreflang attribute to only appear on the English home page.

To fix this issue, I modified index-en.hbs and index-ko.hbs to output the hreflang block from the respective language home pages. Both templates now pass the same set of URLs, ensuring that the hreflang attribute appears on both the English and Korean home pages.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Skandal WordPress vs WP Engine: Pengambilalihan Paksa Plugin ACF

Kronologi Pengambilalihan Plugin ACF oleh WordPress.org Konflik antara WordPress.org dan WP Engine memuncak saat WordPress.org secara sepihak mengambil alih distribusi plugin Advanced Custom Fields…

  • WordPress.org took over ACF plugin distribution unilaterally.
  • Secure Custom Fields (SCF) created as WP Engine safety measure.
  • Ethical concerns raised over unauthorized takeover of third-party code.

Apple Hiring 'iCup' Specialist

Apple recently posted a job listing for an "iCup Supply Specialist" who would be responsible for ensuring that "all Apple employees have access to freshly brewed coffee in their break room." MacRumors…

Refinement E-Graphs

  • Refinement e-graphs expand on traditional e-graphs with built-in = relation.
  • Prototype and WASM demo available at GitHub and personal website.
  • Refinement rewrite rules like rewrite-le and rewrite-ge simplify formulas.

More from Monday 5 October →