diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc
index 4ddfc5e..c14416f 100644
--- a/core/modules/views/views.theme.inc
+++ b/core/modules/views/views.theme.inc
@@ -397,6 +397,12 @@ function template_preprocess_views_view_table(&$variables) {
   // A boolean variable which stores whether the table has a responsive class.
   $responsive = FALSE;
 
+  // For the actual site we want to not render full URLs, because this would
+  // make pagers cacheable per URL, which is problematic in blocks, for example.
+  // For the actual live preview though the javascript relies on properly
+  // working URLs.
+  $route_name = !empty($view->live_preview) ? '<current>' : '<none>';
+
   $query = tablesort_get_query_parameters();
   if (isset($view->exposed_raw_input)) {
     $query += $view->exposed_raw_input;
@@ -438,9 +444,7 @@ function template_preprocess_views_view_table(&$variables) {
         $link_options = array(
           'query' => $query,
         );
-        // It is ok to specify no URL path here as we will always reload the
-        // current page.
-        $url = new Url('<none>', [], $link_options);
+        $url = new Url($route_name, [], $link_options);
         $variables['header'][$field]['url'] = $url->toString();
         $variables['header'][$field]['content'] = $label;
         $variables['header'][$field]['title'] = $title;
diff --git a/core/modules/views_ui/src/Tests/PreviewTest.php b/core/modules/views_ui/src/Tests/PreviewTest.php
index 69d1fee..58acf59 100644
--- a/core/modules/views_ui/src/Tests/PreviewTest.php
+++ b/core/modules/views_ui/src/Tests/PreviewTest.php
@@ -21,7 +21,7 @@ class PreviewTest extends UITestBase {
    *
    * @var array
    */
-  public static $testViews = array('test_preview', 'test_preview_error', 'test_pager_full', 'test_mini_pager');
+  public static $testViews = array('test_preview', 'test_preview_error', 'test_pager_full', 'test_mini_pager', 'test_click_sort');
 
   /**
    * Tests contextual links in the preview form.
@@ -271,6 +271,32 @@ public function testPreviewError() {
   }
 
   /**
+   * Tests the link to sort in the preview form.
+   */
+  public function testPreviewSortLink() {
+
+    // Get the preview.
+    $this->getPreviewAJAX('test_click_sort', 'page_1', 0);
+
+    // Test that the header label is present.
+    $elements = $this->xpath('//th[contains(@class, :class)]/a', array(':class' => 'views-field views-field-name'));
+    $this->assertTrue(!empty($elements), 'The header label is present.');
+
+    // Verify link.
+    $this->assertLinkByHref('preview/page_1?_wrapper_format=drupal_ajax&order=name&sort=desc', 0, 'The output URL is as expected.');
+
+    // Click link to sort.
+    $this->clickPreviewLinkAJAX($elements[0]['href'], 0);
+
+    // Test that the header label is present.
+    $elements = $this->xpath('//th[contains(@class, :class)]/a', array(':class' => 'views-field views-field-name is-active'));
+    $this->assertTrue(!empty($elements), 'The header label is present.');
+
+    // Verify link.
+    $this->assertLinkByHref('preview/page_1?_wrapper_format=drupal_ajax&order=name&sort=asc', 0, 'The output URL is as expected.');
+  }
+
+  /**
    * Get the preview form and force an AJAX preview update.
    *
    * @param string $view_name
