We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Tag pages still use old templates
/tag


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ckan/controllers/tag.py`
Content:
```
1 from pylons.i18n import _
2 from pylons import request, c
3 
4 import ckan.logic as logic
5 import ckan.model as model
6 import ckan.lib.base as base
7 import ckan.lib.helpers as h
8 
9 
10 LIMIT = 25
11 
12 
13 class TagController(base.BaseController):
14 
15     def __before__(self, action, **env):
16         base.BaseController.__before__(self, action, **env)
17         try:
18             context = {'model': model, 'user': c.user or c.author}
19             logic.check_access('site_read', context)
20         except logic.NotAuthorized:
21             base.abort(401, _('Not authorized to see this page'))
22 
23     def index(self):
24         c.q = request.params.get('q', '')
25 
26         context = {'model': model, 'session': model.Session,
27                    'user': c.user or c.author, 'for_view': True}
28 
29         data_dict = {'all_fields': True}
30 
31         if c.q:
32             page = int(request.params.get('page', 1))
33             data_dict['q'] = c.q
34             data_dict['limit'] = LIMIT
35             data_dict['offset'] = (page - 1) * LIMIT
36             data_dict['return_objects'] = True
37 
38         results = logic.get_action('tag_list')(context, data_dict)
39 
40         if c.q:
41             c.page = h.Page(
42                 collection=results,
43                 page=page,
44                 item_count=len(results),
45                 items_per_page=LIMIT
46             )
47             c.page.items = results
48         else:
49             c.page = h.AlphaPage(
50                 collection=results,
51                 page=request.params.get('page', 'A'),
52                 alpha_attribute='name',
53                 other_text=_('Other'),
54             )
55 
56         return base.render('tag/index.html')
57 
58     def read(self, id):
59         context = {'model': model, 'session': model.Session,
60                    'user': c.user or c.author, 'for_view': True}
61 
62         data_dict = {'id': id}
63         try:
64             c.tag = logic.get_action('tag_show')(context, data_dict)
65         except logic.NotFound:
66             base.abort(404, _('Tag not found'))
67 
68         return base.render('tag/read.html')
69
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/ckan/controllers/tag.py b/ckan/controllers/tag.py
--- a/ckan/controllers/tag.py
+++ b/ckan/controllers/tag.py
@@ -1,5 +1,5 @@
 from pylons.i18n import _
-from pylons import request, c
+from pylons import request, c, config
 
 import ckan.logic as logic
 import ckan.model as model
@@ -65,4 +65,7 @@
         except logic.NotFound:
             base.abort(404, _('Tag not found'))
 
-        return base.render('tag/read.html')
+        if h.asbool(config.get('ckan.legacy_templates', False)):
+            return base.render('tag/read.html')
+        else:
+            h.redirect_to(controller='package', action='search', tags=c.tag.get('name'))

{"golden_diff": "diff --git a/ckan/controllers/tag.py b/ckan/controllers/tag.py\n--- a/ckan/controllers/tag.py\n+++ b/ckan/controllers/tag.py\n@@ -1,5 +1,5 @@\n from pylons.i18n import _\n-from pylons import request, c\n+from pylons import request, c, config\n \n import ckan.logic as logic\n import ckan.model as model\n@@ -65,4 +65,7 @@\n         except logic.NotFound:\n             base.abort(404, _('Tag not found'))\n \n-        return base.render('tag/read.html')\n+        if h.asbool(config.get('ckan.legacy_templates', False)):\n+            return base.render('tag/read.html')\n+        else:\n+            h.redirect_to(controller='package', action='search', tags=c.tag.get('name'))\n", "issue": "Tag pages still use old templates\n/tag\n\n", "before_files": [{"content": "from pylons.i18n import _\nfrom pylons import request, c\n\nimport ckan.logic as logic\nimport ckan.model as model\nimport ckan.lib.base as base\nimport ckan.lib.helpers as h\n\n\nLIMIT = 25\n\n\nclass TagController(base.BaseController):\n\n    def __before__(self, action, **env):\n        base.BaseController.__before__(self, action, **env)\n        try:\n            context = {'model': model, 'user': c.user or c.author}\n            logic.check_access('site_read', context)\n        except logic.NotAuthorized:\n            base.abort(401, _('Not authorized to see this page'))\n\n    def index(self):\n        c.q = request.params.get('q', '')\n\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author, 'for_view': True}\n\n        data_dict = {'all_fields': True}\n\n        if c.q:\n            page = int(request.params.get('page', 1))\n            data_dict['q'] = c.q\n            data_dict['limit'] = LIMIT\n            data_dict['offset'] = (page - 1) * LIMIT\n            data_dict['return_objects'] = True\n\n        results = logic.get_action('tag_list')(context, data_dict)\n\n        if c.q:\n            c.page = h.Page(\n                collection=results,\n                page=page,\n                item_count=len(results),\n                items_per_page=LIMIT\n            )\n            c.page.items = results\n        else:\n            c.page = h.AlphaPage(\n                collection=results,\n                page=request.params.get('page', 'A'),\n                alpha_attribute='name',\n                other_text=_('Other'),\n            )\n\n        return base.render('tag/index.html')\n\n    def read(self, id):\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author, 'for_view': True}\n\n        data_dict = {'id': id}\n        try:\n            c.tag = logic.get_action('tag_show')(context, data_dict)\n        except logic.NotFound:\n            base.abort(404, _('Tag not found'))\n\n        return base.render('tag/read.html')\n", "path": "ckan/controllers/tag.py"}], "after_files": [{"content": "from pylons.i18n import _\nfrom pylons import request, c, config\n\nimport ckan.logic as logic\nimport ckan.model as model\nimport ckan.lib.base as base\nimport ckan.lib.helpers as h\n\n\nLIMIT = 25\n\n\nclass TagController(base.BaseController):\n\n    def __before__(self, action, **env):\n        base.BaseController.__before__(self, action, **env)\n        try:\n            context = {'model': model, 'user': c.user or c.author}\n            logic.check_access('site_read', context)\n        except logic.NotAuthorized:\n            base.abort(401, _('Not authorized to see this page'))\n\n    def index(self):\n        c.q = request.params.get('q', '')\n\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author, 'for_view': True}\n\n        data_dict = {'all_fields': True}\n\n        if c.q:\n            page = int(request.params.get('page', 1))\n            data_dict['q'] = c.q\n            data_dict['limit'] = LIMIT\n            data_dict['offset'] = (page - 1) * LIMIT\n            data_dict['return_objects'] = True\n\n        results = logic.get_action('tag_list')(context, data_dict)\n\n        if c.q:\n            c.page = h.Page(\n                collection=results,\n                page=page,\n                item_count=len(results),\n                items_per_page=LIMIT\n            )\n            c.page.items = results\n        else:\n            c.page = h.AlphaPage(\n                collection=results,\n                page=request.params.get('page', 'A'),\n                alpha_attribute='name',\n                other_text=_('Other'),\n            )\n\n        return base.render('tag/index.html')\n\n    def read(self, id):\n        context = {'model': model, 'session': model.Session,\n                   'user': c.user or c.author, 'for_view': True}\n\n        data_dict = {'id': id}\n        try:\n            c.tag = logic.get_action('tag_show')(context, data_dict)\n        except logic.NotFound:\n            base.abort(404, _('Tag not found'))\n\n        if h.asbool(config.get('ckan.legacy_templates', False)):\n            return base.render('tag/read.html')\n        else:\n            h.redirect_to(controller='package', action='search', tags=c.tag.get('name'))\n", "path": "ckan/controllers/tag.py"}]}