Added 'realm' parameter to 'embedded_link_to' helper

Change-Id: I02a2a52e350176361c8420a05cfaa254b8fe2795
diff --git a/Changes b/Changes
index ee8f191..a95afbf 100755
--- a/Changes
+++ b/Changes
@@ -9,6 +9,7 @@
           and deprecated 'doc_uc'.
         - Introduced 'page_title' helper.
         - Simplified documentation routing.
+        - Added 'realm' parameter to 'embedded_link_to' helper.
 
 0.36 2019-09-19
         - Rename all cookies to be independent
diff --git a/lib/Kalamar.pm b/lib/Kalamar.pm
index 322f118..933b79b 100644
--- a/lib/Kalamar.pm
+++ b/lib/Kalamar.pm
@@ -230,7 +230,7 @@
 
   # Set footer value
   $self->content_block(footer => {
-    inline => '<%= embedded_link_to "V ' . $Kalamar::VERSION . '", "korap", "kalamar" %>',
+    inline => '<%= embedded_link_to "doc", "V ' . $Kalamar::VERSION . '", "korap", "kalamar" %>',
     position => 100
   });
 
diff --git a/lib/Kalamar/Plugin/KalamarPages.pm b/lib/Kalamar/Plugin/KalamarPages.pm
index 4c49854..1943542 100644
--- a/lib/Kalamar/Plugin/KalamarPages.pm
+++ b/lib/Kalamar/Plugin/KalamarPages.pm
@@ -19,13 +19,20 @@
   $mojo->helper(
     embedded_link_to => sub {
       my $c = shift;
+
+      # The embedded link now expects at least 3 parameters:
+      #   - The realm, which is identical to the named route
+      #   - The title of the link
+      #   - An optional scope, which is a first level path for navigation
+      #   - The page to link to (accepting a fragment)
+      my $realm = shift;
       my $title = shift;
       my $page = pop;
       my $scope = shift;
 
       ($page, my $fragment) = split '#', $page;
 
-      my $url = $c->url_with('doc' => page => $page, scope => $scope);
+      my $url = $c->url_with($realm, page => $page, scope => $scope);
       $url->fragment($fragment) if $fragment;
       $url->path->canonicalize;
 
@@ -42,7 +49,7 @@
     doc_link_to => sub {
       my $c = shift;
       deprecated 'Deprecated "doc_link_to" in favor of "embedded_link_to"';
-      return $c->embedded_link_to(@_)
+      return $c->embedded_link_to('doc', @_)
     }
   );
 
@@ -259,9 +266,9 @@
 =head2 embedded_link_to
 
   %# In templates
-  %= embedded_link_to 'Kalamar', 'korap', 'kalamar'
+  %= embedded_link_to 'doc','Kalamar', 'korap', 'kalamar'
 
-Create a link to the documentation. Accepts a name, a scope, and a page.
+Create a link to the documentation. Accepts a realm, a title, a scope, and a page.
 
 
 =head2 ext_link_to
diff --git a/t/page.t b/t/page.t
index 61c02d6..fee1205 100644
--- a/t/page.t
+++ b/t/page.t
@@ -10,8 +10,8 @@
 
 is($app->under_construction, '<p>Under Construction!</p>');
 
-is($app->embedded_link_to('privacy', 'privacy'), '<a class="embedded-link" href="/doc/privacy">privacy</a>');
-is($app->embedded_link_to('privacy', 'korap', 'privacy'), '<a class="embedded-link" href="/doc/korap/privacy">privacy</a>');
+is($app->embedded_link_to('doc', 'privacy', 'privacy'), '<a class="embedded-link" href="/doc/privacy">privacy</a>');
+is($app->embedded_link_to('doc', 'privacy', 'korap', 'privacy'), '<a class="embedded-link" href="/doc/korap/privacy">privacy</a>');
 
 
 my $c = $app->build_controller;
diff --git a/templates/de/doc/korap/koral.html.ep b/templates/de/doc/korap/koral.html.ep
index 861eb52..1c52293 100644
--- a/templates/de/doc/korap/koral.html.ep
+++ b/templates/de/doc/korap/koral.html.ep
@@ -6,6 +6,6 @@
 
 <p><strong>Hauptentwickler:</strong> Joachim Bingel</p>
 
-<p>Koral ist eine Bibliothek, die für die Übersetzung verschiedener Korpus-Abfragesprachen nach <%= embedded_link_to('KoralQuery', 'api', 'koralquery')%> konzipiert ist. Derzeit unterstützte Abfragesprachen sind <%= embedded_link_to 'Cosmas II', 'ql', 'cosmas2'%>, <%= embedded_link_to('Annis QL', 'ql', 'annis')%>, <%= embedded_link_to ( 'Poliqarp +', 'ql', 'poliqarp-plus')%> (eine erweiterte Version von Poliqarp) und <%= embedded_link_to('CQL', 'ql', 'cql')%>.
+<p>Koral ist eine Bibliothek, die für die Übersetzung verschiedener Korpus-Abfragesprachen nach <%= embedded_link_to('doc', 'KoralQuery', 'api', 'koralquery')%> konzipiert ist. Derzeit unterstützte Abfragesprachen sind <%= embedded_link_to 'doc', 'Cosmas II', 'ql', 'cosmas2'%>, <%= embedded_link_to('doc', 'Annis QL', 'ql', 'annis')%>, <%= embedded_link_to('doc',  'Poliqarp+', 'ql', 'poliqarp-plus')%> (eine erweiterte Version von Poliqarp) und <%= embedded_link_to('doc', 'CQL', 'ql', 'cql')%>.
 
 <p>Koral ist Open Source und steht unter <%= ext_link_to 'GitHub', "https://github.com/KorAP/Koral"%> zur Verfügung.</p>
diff --git a/templates/de/doc/korap/krill.html.ep b/templates/de/doc/korap/krill.html.ep
index 64aab10..ba138d0 100644
--- a/templates/de/doc/korap/krill.html.ep
+++ b/templates/de/doc/korap/krill.html.ep
@@ -6,6 +6,6 @@
 
 <p><strong>Hauptentwickler:</strong> Nils Diewald, Eliza Margaretha</p>
 
-<p>Krill ist eine <%= ext_link_to 'Lucene', "https://lucene.apache.org/"%> basierte Suchmaschine für große kommentierte Korpora, die als Backend-Komponente für KorAP verwendet wird. Es ist die Referenzimplementierung für <%= embedded_link_to('KoralQuery', 'api', 'koralquery')%>, die die meisten Protokolleigenschaften abdeckt.</p>
+<p>Krill ist eine <%= ext_link_to 'Lucene', "https://lucene.apache.org/"%> basierte Suchmaschine für große kommentierte Korpora, die als Backend-Komponente für KorAP verwendet wird. Es ist die Referenzimplementierung für <%= embedded_link_to('doc', 'KoralQuery', 'api', 'koralquery')%>, die die meisten Protokolleigenschaften abdeckt.</p>
 
 <p>Krill ist Open Source und steht unter <%= ext_link_to 'GitHub', "https://github.com/KorAP/Krill"%> zur Verfügung.</p>
diff --git a/templates/de/doc/ql/poliqarp-plus.html.ep b/templates/de/doc/ql/poliqarp-plus.html.ep
index 9080f8e..d203a98 100644
--- a/templates/de/doc/ql/poliqarp-plus.html.ep
+++ b/templates/de/doc/ql/poliqarp-plus.html.ep
@@ -23,7 +23,7 @@
 
   <h4 id="regexp">Reguläre Ausdrücke</h4>
 
-  <p>Segmente können auch durch <%= embedded_link_to 'Reguläre Ausdrücke', 'ql', 'regexp' %> abgefragt werden - indem das Segment mit doppelten Anführungszeichen umschlossen wird.</p>
+  <p>Segmente können auch durch <%= embedded_link_to 'doc', 'Reguläre Ausdrücke', 'ql', 'regexp' %> abgefragt werden - indem das Segment mit doppelten Anführungszeichen umschlossen wird.</p>
 
   %= doc_query poliqarp => loc('Q_poliqarp_re', '** "r(u|a)n"'), cutoff => 1
 
@@ -72,12 +72,12 @@
 
   %= doc_query poliqarp => loc('Q_poliqarp_complexre', '** [orth="r(u|a)n"/xi]'), cutoff => 1
 
-  <p>Ein weiterer spezieller Schlüssel ist <code>base</code>, bezogen auf die Lemma-Annotation der <%= embedded_link_to 'Standard-Foundry', 'data', 'annotation'%>.
+  <p>Ein weiterer spezieller Schlüssel ist <code>base</code>, bezogen auf die Lemma-Annotation der <%= embedded_link_to 'doc', 'Standard-Foundry', 'data', 'annotation'%>.
     Die folgende Abfrage findet alle Vorkommen von Segmenten, die mit dem eingegebenen Lemma in der Standard-Foundry annotiert wurden.</p>
 
   %= doc_query poliqarp => loc('Q_poliqarp_complexlemma', '** [base=Tree]'), cutoff => 1
 
-  <p>Der dritte Sonderschlüssel ist <code>pos</code> und bezieht sich auf die Wortarten-Annotation der <%= embedded_link_to 'Standard-Foundry', 'data', 'annotation'%>.
+  <p>Der dritte Sonderschlüssel ist <code>pos</code> und bezieht sich auf die Wortarten-Annotation der <%= embedded_link_to 'doc', 'Standard-Foundry', 'data', 'annotation'%>.
     Die folgende Abfrage findet alle attributiven Adjektive:</p>
 
   %= doc_query poliqarp => loc('Q_poliqarp_complexpos', '** [pos=ADJA]'), cutoff => 1
@@ -99,7 +99,7 @@
 
   <blockquote class="warning">
     <p>Vorsicht: Negierte komplexe Segmente können nicht alleinstehend gesucht werden.
-      Allerdings funktionieren sie, wenn sie Teil einer <%= embedded_link_to 'Sequenz', 'ql', 'poliqarp-plus#syntagmatic-operators-sequence'%> sind.</p>
+      Allerdings funktionieren sie, wenn sie Teil einer <%= embedded_link_to 'doc', 'Sequenz', 'ql', 'poliqarp-plus#syntagmatic-operators-sequence'%> sind.</p>
   </blockquote>
 
   <h4 id="empty-segments">Leere Segmente</h4>
@@ -108,11 +108,11 @@
 
   %= doc_query poliqarp => '[]', cutoff => 1
 
-  <p>Leere Segmente sind nützlich, um Abstände von Wörtern auszudrücken, indem sie <%= embedded_link_to 'Wiederholungen', 'ql', 'poliqarp-plus#syntagmatic-operators-repetitions' %> verwenden.</p>
+  <p>Leere Segmente sind nützlich, um Abstände von Wörtern auszudrücken, indem sie <%= embedded_link_to 'doc', 'Wiederholungen', 'ql', 'poliqarp-plus#syntagmatic-operators-repetitions' %> verwenden.</p>
 
   <blockquote class="warning">
     <p>Vorsicht: Leere Segmente können nicht alleinstehend gesucht werden. 
-      Allerdings funktionieren sie, wenn sie Teil einer <%= embedded_link_to 'Sequenz', 'ql', 'poliqarp-plus#syntagmatic-operators-sequence' %> sind.</p>
+      Allerdings funktionieren sie, wenn sie Teil einer <%= embedded_link_to 'doc', 'Sequenz', 'ql', 'poliqarp-plus#syntagmatic-operators-sequence' %> sind.</p>
   </blockquote>
 </section>
 
@@ -193,7 +193,7 @@
 
   <h4 id="syntagmatic-operators-repetitions">Wiederholungen</h4>
 
-  <p>Wiederholungen in Poliqarp werden wie in <%= embedded_link_to 'regulären Ausdrücken', 'ql', 'regexp'%> realisiert, indem Quantifizierer in geschweifte Klammern gesetzt werden.</p>
+  <p>Wiederholungen in Poliqarp werden wie in <%= embedded_link_to 'doc', 'regulären Ausdrücken', 'ql', 'regexp'%> realisiert, indem Quantifizierer in geschweifte Klammern gesetzt werden.</p>
 
     <p>Um eine Sequenz von drei Vorkommen eines Wortes zu suchen, können Sie Ihre Abfrage auf eine der folgenden Arten formulieren - sie werden die selben Ergebnisse erhalten:</p>
 
@@ -234,7 +234,7 @@
     <p>Denken Sie daran, dass Optionalität auf unterschiedliche Arten <i>vererbt</i> sein kann, zum Beispiel wird eine ganze Abfrage optional, sobald ein Segment der Alternative optional ist.</p>
   </blockquote>
 
-  <p>Die Wiederholung kann auch verwendet werden, um Distanzen zwischen Segmenten auszudrücken, indem Sie <%= embedded_link_to 'leere Segmente', 'ql', 'poliqarp-plus # leere Segmente'%> verwenden.</p>
+  <p>Die Wiederholung kann auch verwendet werden, um Distanzen zwischen Segmenten auszudrücken, indem Sie <%= embedded_link_to 'doc', 'leere Segmente', 'ql', 'poliqarp-plus # leere Segmente'%> verwenden.</p>
 
   %= doc_query poliqarp => loc('Q_poliqarp_seqdistance1', '** [base=the][][base=Tree]'), cutoff => 1
   %= doc_query poliqarp => loc('Q_poliqarp_seqdistance2', '** [base=the][]{2}[base=Tree]'), cutoff => 1
@@ -249,7 +249,7 @@
     
   <h4>Positionen</h4>
 
-    <p>Sequenzen wie oben können in weiteren komplexen Abfragen verschachtelt und als Unterabfragen behandelt werden (siehe <%= embedded_link_to 'Klassenoperatoren', 'ql', 'poliqarp-plus#class-operator' %>, um direkten Zugriff auf Unterabfragen zu erhalten).</p>
+    <p>Sequenzen wie oben können in weiteren komplexen Abfragen verschachtelt und als Unterabfragen behandelt werden (siehe <%= embedded_link_to 'doc', 'Klassenoperatoren', 'ql', 'poliqarp-plus#class-operator' %>, um direkten Zugriff auf Unterabfragen zu erhalten).</p>
     
     <p>Positionsoperatoren vergleichen zwei Treffer von Unterabfragen und ergeben einen Treffer, falls eine bestimmte Bedingung bezüglich der Position von beiden wahr ist.</p>
 
diff --git a/templates/doc/api.html.ep b/templates/doc/api.html.ep
index 6aad5cb..4aaacf2 100644
--- a/templates/doc/api.html.ep
+++ b/templates/doc/api.html.ep
@@ -6,4 +6,4 @@
   The specification for KoralQuery is available on <%= ext_link_to 'GitHub', "http://korap.github.io/Koral" %>.
   All API endpoints either use KoralQuery or are (more or lest) REST-ful web APIs.</p>
 
-<p>All publicly available API endpoints including their requests and responses are described in the <%= ext_link_to 'GitHub Wiki', "https://github.com/KorAP/Kustvakt/wiki" %> of <%= embedded_link_to 'Kustvakt', 'korap', 'kustvakt' %>.</p>
+<p>All publicly available API endpoints including their requests and responses are described in the <%= ext_link_to 'GitHub Wiki', "https://github.com/KorAP/Kustvakt/wiki" %> of <%= embedded_link_to 'doc', 'Kustvakt', 'korap', 'kustvakt' %>.</p>
diff --git a/templates/doc/data.html.ep b/templates/doc/data.html.ep
index 514a461..eec65a1 100644
--- a/templates/doc/data.html.ep
+++ b/templates/doc/data.html.ep
@@ -9,7 +9,7 @@
 
 <p>In KorAP, corpus texts are allowed to have arbitrary metadata information, that partially can be used to create subcorpora (so-called virtual corpora).</p>
 
-<p>KorAP also supports an arbitrary number of <%= embedded_link_to 'Annotations', 'data', 'annotation' %> from different sources (called <em>foundries</em>) with different <em>layers</em>.</p>
+<p>KorAP also supports an arbitrary number of <%= embedded_link_to 'doc', 'Annotations', 'data', 'annotation' %> from different sources (called <em>foundries</em>) with different <em>layers</em>.</p>
 
 <dl>
   <p>Annotations of the following kind are supported:</p>
diff --git a/templates/doc/korap.html.ep b/templates/doc/korap.html.ep
index d38e4ae..b7e7091 100644
--- a/templates/doc/korap.html.ep
+++ b/templates/doc/korap.html.ep
@@ -7,22 +7,22 @@
 <p>The KorAP project was launched in 2011 at the <%= ext_link_to 'Leibniz Institute for the German Language (IDS)', "http://www.ids-mannheim.de/" %> in Mannheim, Germany. KorAP is a Corpus Analysis Platform, with an extensible and scalable architecture. It consists of multiple components, that are exchangable due to well defined APIs.</p>
 
 <dl>
-  <dt><%= embedded_link_to('Kalamar', 'korap', 'kalamar') %></dt>
+  <dt><%= embedded_link_to('doc', 'Kalamar', 'korap', 'kalamar') %></dt>
   <dd>Kalamar is the user frontend. Most users will access the search and analysis capabilities of KorAP through the user frontend. The user will formulate queries in one of several query languages that are passed to Kustvakt.</dd>
 
-  <dt><%= embedded_link_to('API', 'api') %></dt>
+  <dt><%= embedded_link_to('doc', 'API', 'api') %></dt>
   <dd>As an alternative to the user frontend, queries can be initiated using a REST web interface directly with Kustvakt.</dd>
 
-  <dt><%= embedded_link_to('Kustvakt', 'korap', 'kustvakt') %></dt>
-  <dd>Kustvakt is the central user and policy management service. It takes a query and rewrites it to restrict the scope of a search to documents the user is allowed to. It may also inject further properties the user has set up, like preferred annotation layers. To transfer a query written in a certain query language to the internal general query protocol <%= embedded_link_to('KoralQuery', 'api', 'koralquery') %>, Kustvakt uses <%= embedded_link_to('Koral', 'korap', 'koral') %>.</dd>
+  <dt><%= embedded_link_to('doc', 'Kustvakt', 'korap', 'kustvakt') %></dt>
+  <dd>Kustvakt is the central user and policy management service. It takes a query and rewrites it to restrict the scope of a search to documents the user is allowed to. It may also inject further properties the user has set up, like preferred annotation layers. To transfer a query written in a certain query language to the internal general query protocol <%= embedded_link_to('doc', 'KoralQuery', 'api', 'koralquery') %>, Kustvakt uses <%= embedded_link_to('doc', 'Koral', 'korap', 'koral') %>.</dd>
 
-  <dt><%= embedded_link_to('Koral', 'korap', 'koral') %></dt>
-  <dd>Koral is a library that translates queries written in one of several implemented query languages into a general query protocol, called <%= embedded_link_to('KoralQuery', 'api', 'koralquery') %>.</dd>
+  <dt><%= embedded_link_to('doc', 'Koral', 'korap', 'koral') %></dt>
+  <dd>Koral is a library that translates queries written in one of several implemented query languages into a general query protocol, called <%= embedded_link_to('doc', 'KoralQuery', 'api', 'koralquery') %>.</dd>
 
-  <dt><%= embedded_link_to('Krill', 'korap', 'krill') %></dt>
-  <dd>Krill is a Lucene based backend engine that can search large corpora for occurrences of search patterns formulated in <%= embedded_link_to('KoralQuery', 'api', 'koralquery') %>.</dd>
+  <dt><%= embedded_link_to('doc', 'Krill', 'korap', 'krill') %></dt>
+  <dd>Krill is a Lucene based backend engine that can search large corpora for occurrences of search patterns formulated in <%= embedded_link_to('doc', 'KoralQuery', 'api', 'koralquery') %>.</dd>
 
-  <dt><%= embedded_link_to('Karang', 'korap', 'karang') %></dt>
+  <dt><%= embedded_link_to('doc', 'Karang', 'korap', 'karang') %></dt>
   <dd>Karang is a Neo4j based backend engine that can traverse large corpora represented as graphs.</dd>
 </dl>
 
diff --git a/templates/doc/korap/koral.html.ep b/templates/doc/korap/koral.html.ep
index 9af7508..44f07b4 100644
--- a/templates/doc/korap/koral.html.ep
+++ b/templates/doc/korap/koral.html.ep
@@ -6,6 +6,6 @@
 
 <p><strong>Main developer:</strong> Joachim Bingel</p>
 
-<p>Koral is a library designed for the translation of different corpus query languages to <%= embedded_link_to('KoralQuery', 'api', 'koralquery') %>. Currently supported query languages include <%= embedded_link_to 'Cosmas II', 'ql', 'cosmas2' %>, <%= embedded_link_to('Annis QL', 'ql', 'annis') %>, <%= embedded_link_to('Poliqarp+', 'ql', 'poliqarp-plus') %> (an extended version of Poliqarp) and <%= embedded_link_to('CQL', 'ql', 'cql') %>.</p>
+<p>Koral is a library designed for the translation of different corpus query languages to <%= embedded_link_to('doc', 'KoralQuery', 'api', 'koralquery') %>. Currently supported query languages include <%= embedded_link_to 'doc', 'Cosmas II', 'ql', 'cosmas2' %>, <%= embedded_link_to('doc', 'Annis QL', 'ql', 'annis') %>, <%= embedded_link_to('doc', 'Poliqarp+', 'ql', 'poliqarp-plus') %> (an extended version of Poliqarp) and <%= embedded_link_to('doc', 'CQL', 'ql', 'cql') %>.</p>
 
 <p>Koral is open source and available on <%= ext_link_to 'GitHub', "https://github.com/KorAP/Koral" %>.</p>
diff --git a/templates/doc/korap/krill.html.ep b/templates/doc/korap/krill.html.ep
index dcf1fe0..e36b6c8 100644
--- a/templates/doc/korap/krill.html.ep
+++ b/templates/doc/korap/krill.html.ep
@@ -6,6 +6,6 @@
 
 <p><strong>Main developer:</strong> Nils Diewald, Eliza Margaretha</p>
 
-<p>Krill is a <%= ext_link_to 'Lucene', "https://lucene.apache.org/" %> based search engine for large annotated corpora, used as a backend component for KorAP. It is the reference implementation for <%= embedded_link_to('KoralQuery', 'api', 'koralquery') %>, covering most of the protocols features.</p>
+<p>Krill is a <%= ext_link_to 'Lucene', "https://lucene.apache.org/" %> based search engine for large annotated corpora, used as a backend component for KorAP. It is the reference implementation for <%= embedded_link_to('doc', 'KoralQuery', 'api', 'koralquery') %>, covering most of the protocols features.</p>
 
 <p>Krill is open source and available on <%= ext_link_to 'GitHub', "https://github.com/KorAP/Krill" %>.</p>
diff --git a/templates/doc/ql.html.ep b/templates/doc/ql.html.ep
index d09eeb6..5bee3a5 100644
--- a/templates/doc/ql.html.ep
+++ b/templates/doc/ql.html.ep
@@ -9,34 +9,34 @@
 <section id="examples">
   <h3>Example Queries</h3>
   
-  <p><strong><%= embedded_link_to 'Poliqarp', 'ql', 'poliqarp-plus' %></strong>: Find all occurrences of the lemma &quot;baum&quot; as annotated by the <%= embedded_link_to 'default foundry', 'data', 'annotation' %>.</p>
+  <p><strong><%= embedded_link_to 'doc', 'Poliqarp', 'ql', 'poliqarp-plus' %></strong>: Find all occurrences of the lemma &quot;baum&quot; as annotated by the <%= embedded_link_to 'doc', 'default foundry', 'data', 'annotation' %>.</p>
   %= doc_query poliqarp => '[base=Baum]'
 
-  <p><strong><%= embedded_link_to 'Poliqarp', 'ql', 'poliqarp-plus' %></strong>: Find all sequences of adjectives as annotated by Treetagger, that are repeated 3 to 5 times in a row.</p>
+  <p><strong><%= embedded_link_to 'doc', 'Poliqarp', 'ql', 'poliqarp-plus' %></strong>: Find all sequences of adjectives as annotated by Treetagger, that are repeated 3 to 5 times in a row.</p>
   %= doc_query poliqarp => '[tt/p=ADJA]{3,5}'
 
-  <p><strong><%= embedded_link_to 'Cosmas-II', 'ql', 'cosmas-2' %></strong>: Find all occurrences of the words &quot;der&quot; and &quot;Baum&quot;, in case they are in a maximum distance of 5 tokens. The order is not relevant.</p>
+  <p><strong><%= embedded_link_to 'doc', 'Cosmas-II', 'ql', 'cosmas-2' %></strong>: Find all occurrences of the words &quot;der&quot; and &quot;Baum&quot;, in case they are in a maximum distance of 5 tokens. The order is not relevant.</p>
   %= doc_query cosmas2 => 'der /w5 Baum'
 
-  <p><strong><%= embedded_link_to 'Cosmas-II', 'ql', 'cosmas-2' %></strong>: Find all sequences of a word starting with a &quot;d&quot; (using a wildcard) followed by an adjective as annotated in the mate foundry, followed by the word &quot;Baum&quot; (ignore the case), that is in a sentence element annotated by the <%= embedded_link_to 'default foundry', 'data', 'annotation' %>.</p>
+  <p><strong><%= embedded_link_to 'doc', 'Cosmas-II', 'ql', 'cosmas-2' %></strong>: Find all sequences of a word starting with a &quot;d&quot; (using a wildcard) followed by an adjective as annotated in the mate foundry, followed by the word &quot;Baum&quot; (ignore the case), that is in a sentence element annotated by the <%= embedded_link_to 'doc', 'default foundry', 'data', 'annotation' %>.</p>
   <p><em>Be aware</em>: Minor incompatibilities with implemented languages may be announced with warnings.</p>
   %= doc_query cosmas2 => 'd* MORPH(mate/p=ADJA) $Baum #IN #ELEM(s)'
 
-  <p><strong><%= embedded_link_to 'Poliqarp+', 'ql', 'poliqarp-plus' %></strong>: Find all nominal phrases as annotated using CoreNLP, that contain an adverb as annotated by OpenNLP, that is annotated as something starting with an &quot;A&quot; using regular expressions in Treetagger.</p>
+  <p><strong><%= embedded_link_to 'doc', 'Poliqarp+', 'ql', 'poliqarp-plus' %></strong>: Find all nominal phrases as annotated using CoreNLP, that contain an adverb as annotated by OpenNLP, that is annotated as something starting with an &quot;A&quot; using regular expressions in Treetagger.</p>
   %= doc_query poliqarp => 'contains(<corenlp/c=NP>,{[opennlp/p=ADV & tt/p="A.*"]})', cutoff => 1
 
-  <p><strong><%= embedded_link_to 'Poliqarp+', 'ql', 'poliqarp-plus' %></strong>: Find all sentences as annotated by the base foundry that start with a sequence of one token in present tense as annotated by Marmot and the lemma &quot;die&quot; annotated by the <%= embedded_link_to 'default foundry', 'data', 'annotation' %>. Highlight both terms of the sequence.</p>
+  <p><strong><%= embedded_link_to 'doc', 'Poliqarp+', 'ql', 'poliqarp-plus' %></strong>: Find all sentences as annotated by the base foundry that start with a sequence of one token in present tense as annotated by Marmot and the lemma &quot;die&quot; annotated by the <%= embedded_link_to 'doc', 'default foundry', 'data', 'annotation' %>. Highlight both terms of the sequence.</p>
   %= doc_query poliqarp => 'startswith(<base/s=s>, {1:[marmot/m=tense:pres]}{2:[base=die]})', cutoff => 1
 
-  <p><strong><%= embedded_link_to 'Poliqarp+', 'ql', 'poliqarp-plus' %></strong>: Find all sequences of an article, followed by three to four adjectives and a noun as annotated by the Treetagger foundry, that finish a sentence. Highlight all parts of the sequence.</p>
+  <p><strong><%= embedded_link_to 'doc', 'Poliqarp+', 'ql', 'poliqarp-plus' %></strong>: Find all sequences of an article, followed by three to four adjectives and a noun as annotated by the Treetagger foundry, that finish a sentence. Highlight all parts of the sequence.</p>
   %= doc_query poliqarp => 'focus(3:endswith(<base/s=s>,{3:[tt/p=ART]{1:{2:[tt/p=ADJA]{3,4}}[tt/p=NN]}}))', cutoff => 1
 
-  <p><strong><%= embedded_link_to 'Annis', 'ql', 'annis' %></strong>: Find all occurrences of the sequence of two tokens annotated as adverbs by the <%= embedded_link_to 'default foundry', 'data', 'annotation' %>.</p>
+  <p><strong><%= embedded_link_to 'doc', 'Annis', 'ql', 'annis' %></strong>: Find all occurrences of the sequence of two tokens annotated as adverbs by the <%= embedded_link_to 'doc', 'default foundry', 'data', 'annotation' %>.</p>
   %= doc_query annis => 'pos="ADV" & pos="ADV" & #1 . #2'
 
-  <p><strong><%= embedded_link_to 'Annis', 'ql', 'annis' %></strong>: Find all determiner relations with the label <code>DET</code> by MALT where the relation sources are attributive possesive pronouns annotated by Tree Tagger.</p>
+  <p><strong><%= embedded_link_to 'doc', 'Annis', 'ql', 'annis' %></strong>: Find all determiner relations with the label <code>DET</code> by MALT where the relation sources are attributive possesive pronouns annotated by Tree Tagger.</p>
   %= doc_query annis => 'tt/p="PPOSAT" ->malt/d[func="DET"] node'
 
-  <p><strong><%= embedded_link_to 'CQL', 'ql', 'cql' %></strong>: Find all occurrences of the sequence &quot;der alte Mann&quot;.</p>
+  <p><strong><%= embedded_link_to 'doc', 'CQL', 'ql', 'cql' %></strong>: Find all occurrences of the sequence &quot;der alte Mann&quot;.</p>
   %= doc_query cql => '"der alte Mann"'	
 </section>
diff --git a/templates/doc/ql/annis.html.ep b/templates/doc/ql/annis.html.ep
index 24a2145..b1b17dc 100644
--- a/templates/doc/ql/annis.html.ep
+++ b/templates/doc/ql/annis.html.ep
@@ -9,7 +9,7 @@
   pairs, relations). The concept of AQL is similar to searching node elements and edges
   between them, where a node element can be a token or an attribute-value pair.</p>
 
-<p>KorAP supports the following keywords by using the <%= embedded_link_to 'default foundries', 'data', 'annotation' %>: </p>
+<p>KorAP supports the following keywords by using the <%= embedded_link_to 'doc', 'default foundries', 'data', 'annotation' %>: </p>
 <dl>
   <dt><code>node</code></dt>
   <dd>a node element</dd>
diff --git a/templates/doc/ql/cosmas-2.html.ep b/templates/doc/ql/cosmas-2.html.ep
index d320eb3..f0be87f 100644
--- a/templates/doc/ql/cosmas-2.html.ep
+++ b/templates/doc/ql/cosmas-2.html.ep
@@ -30,7 +30,7 @@
 
   <h4>Lemma Operator</h4>
   
-  <p>Instead of searching for the surface form of a word, a lemma (as annotated by the <%= embedded_link_to 'default foundry', 'data', 'annotation' %>) can be requested by prepending the term with the <code>&amp;</code> operator. The form of the lemma is dependent on the annotation.</p>
+  <p>Instead of searching for the surface form of a word, a lemma (as annotated by the <%= embedded_link_to 'doc', 'default foundry', 'data', 'annotation' %>) can be requested by prepending the term with the <code>&amp;</code> operator. The form of the lemma is dependent on the annotation.</p>
   <%= doc_query cosmas2 => '&laufen' %>
 
   <h4>Case Insensitivity Operator</h4>
@@ -40,11 +40,11 @@
 
   <h4>Regular Expression Operator</h4>
 
-  <p>By using the <code>#REG(...)</code> operator, query terms can be formulated using <%= embedded_link_to 'regular expressions', 'ql', 'regexp' %>.</p>
+  <p>By using the <code>#REG(...)</code> operator, query terms can be formulated using <%= embedded_link_to 'doc', 'regular expressions', 'ql', 'regexp' %>.</p>
   
 
   <blockquote class="bug">
-    <p>Regular expressions in COSMAS II are not yet properly implemented in KorAP. If you want to use regular expressions, please refer to <%= embedded_link_to 'Poliqarp', 'ql', 'poliqarp-plus#regexp' %>.</p>
+    <p>Regular expressions in COSMAS II are not yet properly implemented in KorAP. If you want to use regular expressions, please refer to <%= embedded_link_to 'doc', 'Poliqarp', 'ql', 'poliqarp-plus#regexp' %>.</p>
   </blockquote>
 
 </section>
@@ -84,7 +84,7 @@
 %#    <p>Currently, intervals are interpreted as MIN:MAX only, while COSMAS 2 defines intervals as being MAX:MIN, while taking the smaller number as being the minimum value of the interval and the greater number as being the maximum value of the interval. <%= ext_link_to 'KorAP will adopt the behaviour of COSMAS II in the near future', "https://github.com/KorAP/Koral/issues/67" %>.</p>
 %#  </blockquote>
   
-  <p>Distance operators rely on the <%= embedded_link_to 'default foundry', 'data', 'annotation' %> annotation for document structures.</p>
+  <p>Distance operators rely on the <%= embedded_link_to 'doc', 'default foundry', 'data', 'annotation' %> annotation for document structures.</p>
 
   <h4>Word Distance Operator</h4>
 
@@ -105,7 +105,7 @@
   <h4>Sentence Distance Operator</h4>
 
   <p>The sentence distance operator <code>s</code> defines how many sentences are allowed or are not allowed in-between two search operands.</p>
-  <p>The sentence distance relies on the <%= embedded_link_to 'default foundry', 'data', 'annotation' %> annotation for document structures.</p>
+  <p>The sentence distance relies on the <%= embedded_link_to 'doc', 'default foundry', 'data', 'annotation' %> annotation for document structures.</p>
 
   <p>Search for two operands occuring in the same or a following sentence in arbitrary order:</p>
   %= doc_query cosmas2 => 'offen /s1 Geschäft'
@@ -119,7 +119,7 @@
   <h4>Paragraph Distance Operator</h4>
 
   <p>The paragraph distance operator <code>p</code> defines how many paragraphs are allowed or are not allowed in-between two search operands.</p>
-  <p>The paragraph distance relies on the <%= embedded_link_to 'default foundry', 'data', 'annotation' %> annotation for document structures.</p>
+  <p>The paragraph distance relies on the <%= embedded_link_to 'doc', 'default foundry', 'data', 'annotation' %> annotation for document structures.</p>
 
   <p>Search for two operands occuring in the same or a following paragraph in arbitrary order:</p>
   %= doc_query cosmas2 => 'offen /p1 Geschäft'
diff --git a/templates/doc/ql/fcsql.html.ep b/templates/doc/ql/fcsql.html.ep
index 843438e..735ce8b 100644
--- a/templates/doc/ql/fcsql.html.ep
+++ b/templates/doc/ql/fcsql.html.ep
@@ -6,7 +6,7 @@
   <%= ext_link_to 'Clarin Federated Content Search (FCS)', "https://www.clarin.eu/content/federated-content-search-clarin-fcs" %>,
   that allows searching through annotated data.
 Accordingly, FCS-QL is primarily intended to represent queries involving annotation layers
-such as part-of-speech and lemma. FCS-QL grammar is fairly similar to <%= embedded_link_to 'Poliqarp', 'ql', 'poliqarp-plus' %> since it was
+such as part-of-speech and lemma. FCS-QL grammar is fairly similar to <%= embedded_link_to 'doc', 'Poliqarp', 'ql', 'poliqarp-plus' %> since it was
 built heavily based on Poliqarp/CQP.</p>
 
 <p>In FCS-QL, foundries are called qualifiers. A combination of a foundry and a layer is
@@ -43,7 +43,7 @@
   %= doc_query fcsql => '[text = "Semmel"]', cutoff => 1
   %= doc_query fcsql => '[text = "essen"/c]', cutoff => 1
 	
-	<p>Querying adverbs from the <%= embedded_link_to 'default foundry', 'data', 'annotation' %>.</p>
+	<p>Querying adverbs from the <%= embedded_link_to 'doc', 'default foundry', 'data', 'annotation' %>.</p>
   %= doc_query fcsql => '[pos="ADV"]', cutoff => 1
 	
 
@@ -72,7 +72,7 @@
 	
 
   <h4>Empty token</h4>
-	<p>Like in <%= embedded_link_to 'Poliqarp', 'ql', 'poliqarp-plus' %>, an empty token is signified by <code>[]</code>
+	<p>Like in <%= embedded_link_to 'doc', 'Poliqarp', 'ql', 'poliqarp-plus' %>, an empty token is signified by <code>[]</code>
     which means any token. Due to the
 	excessive number of results, empty token is not allowed to be used independently, but in
 	combination with other tokens, for instance in a sequence query.</p>
diff --git a/templates/doc/ql/poliqarp-plus.html.ep b/templates/doc/ql/poliqarp-plus.html.ep
index 6dabcbc..e97fbdd 100644
--- a/templates/doc/ql/poliqarp-plus.html.ep
+++ b/templates/doc/ql/poliqarp-plus.html.ep
@@ -24,7 +24,7 @@
 
   <h4 id="regexp">Regular Expressions</h4>
 
-  <p>Segments can also be queried using <%= embedded_link_to 'regular expressions', 'ql', 'regexp' %> - by surrounding the segment with double quotes.</p>
+  <p>Segments can also be queried using <%= embedded_link_to 'doc', 'regular expressions', 'ql', 'regexp' %> - by surrounding the segment with double quotes.</p>
 
   %= doc_query poliqarp => loc('Q_poliqarp_re', '** "r(u|a)n"'), cutoff => 1
 
@@ -70,12 +70,12 @@
 
   %= doc_query poliqarp => loc('Q_poliqarp_complexre', '** [orth="r(u|a)n"/xi]'), cutoff => 1
 
-  <p>Another special key is <code>base</code>, refering to the lemma annotation of the <%= embedded_link_to 'default foundry', 'data', 'annotation' %>.
+  <p>Another special key is <code>base</code>, refering to the lemma annotation of the <%= embedded_link_to 'doc', 'default foundry', 'data', 'annotation' %>.
     The following query finds all occurrences of segments annotated as a specified lemma by the default foundry.</p>
 
   %= doc_query poliqarp => loc('Q_poliqarp_complexlemma', '** [base=Tree]'), cutoff => 1
 
-  <p>The third special key is <code>pos</code>, refering to the part-of-speech annotation of the <%= embedded_link_to 'default foundry', 'data', 'annotation' %>.
+  <p>The third special key is <code>pos</code>, refering to the part-of-speech annotation of the <%= embedded_link_to 'doc', 'default foundry', 'data', 'annotation' %>.
     The following query finds all attributive adjectives:</p>
 
   %= doc_query poliqarp => loc('Q_poliqarp_complexpos', '** [pos=ADJA]'), cutoff => 1
@@ -97,7 +97,7 @@
 
   <blockquote class="warning">
     <p>Beware: Negated complex segments can't be searched as a single statement.
-      However, they work in case they are part of a <%= embedded_link_to 'sequence', 'ql', 'poliqarp-plus#syntagmatic-operators-sequence' %>.</p>
+      However, they work in case they are part of a <%= embedded_link_to 'doc', 'sequence', 'ql', 'poliqarp-plus#syntagmatic-operators-sequence' %>.</p>
   </blockquote>
 
   <h4 id="empty-segments">Empty Segments</h4>
@@ -106,11 +106,11 @@
 
   %= doc_query poliqarp => '[]', cutoff => 1
 
-  <p>Empty segments are useful to express distances of words by using <%= embedded_link_to 'repetitions', 'ql', 'poliqarp-plus#syntagmatic-operators-repetitions' %>.</p>
+  <p>Empty segments are useful to express distances of words by using <%= embedded_link_to 'doc', 'repetitions', 'ql', 'poliqarp-plus#syntagmatic-operators-repetitions' %>.</p>
 
   <blockquote class="warning">
     <p>Beware: Empty segments can't be searched as a single statement.
-      However, they work in case they are part of a <%= embedded_link_to 'sequence', 'ql', 'poliqarp-plus#syntagmatic-operators-sequence' %>.</p>
+      However, they work in case they are part of a <%= embedded_link_to 'doc', 'sequence', 'ql', 'poliqarp-plus#syntagmatic-operators-sequence' %>.</p>
   </blockquote>
 </section>
 
@@ -191,7 +191,7 @@
 
   <h4 id="syntagmatic-operators-repetitions">Repetition</h4>
 
-  <p>Repetitions in Poliqarp are realized as in <%= embedded_link_to 'regular expressions', 'ql', 'regexp' %>, by giving quantifieres in curly brackets.</p>
+  <p>Repetitions in Poliqarp are realized as in <%= embedded_link_to 'doc', 'regular expressions', 'ql', 'regexp' %>, by giving quantifieres in curly brackets.</p>
   <p>To search for a sequence of three occurrences of a defined string, you can formulate your query in any of the following ways - they will have the same results:</p>
 
   %= doc_query poliqarp => loc('Q_poliqarp_repmanual', '** the the the'), cutoff => 1
@@ -231,7 +231,7 @@
     <p>Keep in mind that optionality may be somehow <i>inherited</i>, for example an entire query becomes optional as soon as one segment of an alternation is optional.</p>
   </blockquote>
 
-  <p>Repetition can also be used to express distances between segments by using <%= embedded_link_to 'empty segments', 'ql', 'poliqarp-plus#empty-segments' %>.</p>
+  <p>Repetition can also be used to express distances between segments by using <%= embedded_link_to 'doc', 'empty segments', 'ql', 'poliqarp-plus#empty-segments' %>.</p>
 
   %= doc_query poliqarp => loc('Q_poliqarp_seqdistance1', '** [base=the][][base=Tree]'), cutoff => 1
   %= doc_query poliqarp => loc('Q_poliqarp_seqdistance2', '** [base=the][]{2}[base=Tree]'), cutoff => 1
@@ -246,7 +246,7 @@
     
   <h4>Position</h4>
 
-  <p>Sequences as shown above can all be nested in further complex queries and treated as subqueries (see <%= embedded_link_to 'class operators', 'ql', 'poliqarp-plus#class-operators' %> on how to later access these subqueries directly).</p>
+  <p>Sequences as shown above can all be nested in further complex queries and treated as subqueries (see <%= embedded_link_to 'doc', 'class operators', 'ql', 'poliqarp-plus#class-operators' %> on how to later access these subqueries directly).</p>
   <p>Positional operators compare two matches of subqueries and will match, in case a certain condition regarding the position of both is true.</p>
   <p>The <code>contains()</code> operation will match, when a second subquery matches inside the span of a first subquery.</p>