Urgent.News

What's breaking now, across thousands of outlets.

Tech

Multilingual Ghost CMS Blog: 5. Making Home Links Language Aware

This explains how to make the home links in the navigation bar, footer, and error page point to the correct language-specific homepage. Home link in the navigation bar Home link in the footer Home link on the error page There are home links in the navigation bar, footer, and error page. These links are set to @site .url, and regardless of the multilingual settings, they only point to the main…

This guide details how to configure the home navigation links on a multilingual Ghost CMS blog to point to the appropriate language-specific homepage. The home links can be found in the navigation bar, footer, and error page. These links are currently set to point to the main page of the default language, regardless of the multilingual settings. The objective is to modify them so they direct to the active language instead.

The default.hbs file already functions correctly when handling the block lang in an if condition. However, this method does not work properly on the error page or tag page as they do not include index-ko or index-en and do not explicitly assign lang values like post or page do. Instead of relying on lang, a new approach is adopted to retrieve the selectedLanguage value stored in localStorage and update the URL accordingly.

To implement this, separate functions are created and stored in a util.js file for reusability across multiple files. The getSelectedLanguage function retrieves the selectedLanguage value from localStorage, default to en if not found. The updateLink function updates the href of a specified selector based on the selected language. These functions are then loaded from the js/util.js file using the {{asset}} helper.

The error-404.hbs, error.hbs, and tag.hbs files are updated to incorporate the getSelectedLanguage and updateLink functions. In error.hbs, JavaScript is added to change the href of the .error-link based on the selected language. Similarly, in error.hbs and tag.hbs, JavaScript is added to change the href of .error-link and .site-nav-logo respectively based on the selected language.

The default.hbs file also includes a function that initializes the language selector. This function checks if the current URL includes /tag/ and sets the selected language accordingly in localStorage and the language selector. It then listens for a change event on the language selector and updates the href of .gh-head-logo, section.copyright a, and li.nav-home a based on the selected language.

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

UK Hackathon Statistics

This is a submission for the Hacktoberfest Weekend Challenge: Build for a Friend What I Built hackreport is a pipeline that reads public pages about past UK hackathons and reports on the student-led…

  • Hackreport compiles UK hackathon statistics season by season
  • Focuses on student-led events, recording organizer and project size
  • Open-source project with Gemma 3 (4B) model, accessible online

5 Excel chores worth automating with Python (and how to tell which ones aren't)

Most "Excel problems" I get asked about are not Excel problems. They are the same five boring steps someone does every Monday by hand.

  • Automate Excel tasks with Python to save time and reduce manual effort.
  • Evaluate tasks based on clicks and time spent, not just row count.
  • Ensure scripts are user-friendly, preserving data integrity and file integrity.

I built a handover board for the friend who was doing all the remembering

I built a handover board for the friend who was doing all the remembering This is a DEV Hacktoberfest Weekend Challenge submission: Build for a Friend .

  • Friend developed handover board to manage medication schedule
  • Board logs doses, blood pressures, medical notes, appointments
  • System uses openFDA, NIH RxNorm for accuracy and data integrity

More from Saturday 3 October →