Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

General

Base URL (Again!)

Started by Casper Labuschagne 9 years ago · 2 replies · 1684 views
9 years ago

Hi, I have a multilingual site (af | en).

There will always be a locahost development site and a production site.

The problem is with multilanguage URL rewriting eg. http://mysite/en and http://mysite/af (which is good and is what I want) where stable links in markdown text becomes mangled eg. http://mysite/en that becomes http://mysite/en/af

An explanation of what happens:

A link on an Afrikaans page in Markdown will be [mylink](/af/mypage) but this becomes http://mysite/af/af/mypage

Now if something like this existed, it would solve my problems: [mylink](%base_url%/af/mypage)

Yes, I can enter the full URL in markdown [linktext](http://mysite/af/mypage) but then my localhost site becomes painful to use and debug.

Yes, I searched and I spent a long time searching for something like a %base_url% variable, but without success.

Thanks in advance, any pointers in the right direction will be appreciated.

last edited 09/16/17 by Casper Labuschagne
9 years ago

Just an update, the LangSwitcher plugin solved my requirement for a stable link to switch languages that works on both a localhost site as well as the hosted site.

However, in the case of multilingual sites, on-page links such as this gets mangled, [mylink-text-in-afrikaans](/af/mylink) which becomes http://localsite/en/af/mylink when choosing the alternate translated page. To get stable on-page links, a full url has to be specified [mylink-text-in-afrikaans](http://mysite/af/mylink) which affects the development on a localhost site where links won't work.

I presume I should open a bug/feature request (or possibly develop a plugin?) for something like a %base_url% type variable that will point the the actual base URL in use, that can be used like this: [mylink-text-in-afrikaans](%base_url%/af/mylink)

Suggested topics

Topic Participants Replies Views Activity
General · by Jerry Hunt, 4 days ago
2 76 7 hours ago
General · by pamtbaau, 13 hours ago
1 47 12 hours ago
General · by Andy Miller, 1 day ago
0 44 1 day ago
General · by Marcel, 12 months ago
6 346 5 days ago
General · by Duc , 5 days ago
3 40 5 days ago