[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] hreflang: add self-referential alternate link for wiki pages

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <689e39bd2e492_2c4db375c101129@gitlab-sidekiq-low-urgency-cpu-bound-v2-56796cf4dc-7fv46.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
88045800 by Olivier Kango at 2025-08-14T19:24:13+00:00
[FIX] hreflang: add self-referential alternate link for wiki pages
---
* [FIX] hreflang: add self-referential alternate link for wiki pages

- Add self alternate <link rel="alternate"> for the current wiki page.
- Use TikiLib::lib('wiki')->sefurl($this->page) so the self href equals the canonical URL.
- Keep existing alternate links for other translations unchanged.

This fixes the task “Issue with hreflang tag in the page header” where
pages only emitted alternates for other languages but not for themselves.

Ref: https://dev.tiki.org/item8806

See merge request tikiwiki/tiki!8299

- - - - -


1 changed file:

- lib/wiki/renderlib.php


Changes:

=====================================
lib/wiki/renderlib.php
=====================================
@@ -215,6 +215,12 @@ class WikiRenderer
 
             $headerlib = TikiLib::lib('header');
             $links = [];
+
+            $wikilib = TikiLib::lib('wiki');
+            $selfHref = $wikilib->sefurl($this->page);
+
+            $links[] = '<link rel="alternate" href="' . $selfHref . '" hreflang="' . $this->info['lang'] . '">';
+
             foreach ($this->trads as $trad) {
                 if ($trad['lang'] != $this->info['lang']) {
                     $links[] = '<link rel="alternate" href="tiki-index.php?page=' . $trad['objName'] . '" hreflang="' . $trad['lang'] . '">';



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/8804580014d0de24c5fa7e6a363a695b623f46d7

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/8804580014d0de24c5fa7e6a363a695b623f46d7
You're receiving this email because of your account on gitlab.com.

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.