diff --git a/datasette/templates/_action_menu.html b/datasette/templates/_action_menu.html
new file mode 100644
index 0000000000..7d1d4a555b
--- /dev/null
+++ b/datasette/templates/_action_menu.html
@@ -0,0 +1,28 @@
+{% if action_links %}
+
+{% endif %}
\ No newline at end of file
diff --git a/datasette/templates/database.html b/datasette/templates/database.html
index b5a0edc4d3..4a4a05cbf2 100644
--- a/datasette/templates/database.html
+++ b/datasette/templates/database.html
@@ -13,36 +13,8 @@
-{% set links = database_actions() %}{% if links %}
-
-{% endif %}
+{% set action_links, action_title = database_actions(), "Database actions" %}
+{% include "_action_menu.html" %}
{{ top_database() }}
diff --git a/datasette/templates/index.html b/datasette/templates/index.html
index d08cdb1017..6e95126ddc 100644
--- a/datasette/templates/index.html
+++ b/datasette/templates/index.html
@@ -7,36 +7,8 @@
{% block content %}
{{ metadata.title or "Datasette" }}{% if private %} 🔒{% endif %}
-{% set links = homepage_actions %}{% if links %}
-
-{% endif %}
+{% set action_links, action_title = homepage_actions, "Homepage actions" %}
+{% include "_action_menu.html" %}
{{ top_homepage() }}
diff --git a/datasette/templates/query.html b/datasette/templates/query.html
index 09a29118b9..f7c8d0a3f7 100644
--- a/datasette/templates/query.html
+++ b/datasette/templates/query.html
@@ -29,37 +29,8 @@
{% endif %}
{{ metadata.title or database }}{% if canned_query and not metadata.title %}: {{ canned_query }}{% endif %}{% if private %} 🔒{% endif %}
-{% set links = query_actions() %}{% if links %}
-
-{% endif %}
-
+{% set action_links, action_title = query_actions(), "Query actions" %}
+{% include "_action_menu.html" %}
{% if canned_query %}{{ top_canned_query() }}{% else %}{{ top_query() }}{% endif %}
diff --git a/datasette/templates/row.html b/datasette/templates/row.html
index c3e6bed73a..db43e71a60 100644
--- a/datasette/templates/row.html
+++ b/datasette/templates/row.html
@@ -22,36 +22,8 @@
{% block content %}
{{ table }}: {{ ', '.join(primary_key_values) }}{% if private %} 🔒{% endif %}
-{% set links = row_actions %}{% if links %}
-
-{% endif %}
+{% set action_links, action_title = row_actions, "Row actions" %}
+{% include "_action_menu.html" %}
{{ top_row() }}
diff --git a/datasette/templates/table.html b/datasette/templates/table.html
index 505335d6e7..35e0b9c1b6 100644
--- a/datasette/templates/table.html
+++ b/datasette/templates/table.html
@@ -24,36 +24,8 @@
-{% set links = actions() %}{% if links %}
-
-{% endif %}
+{% set action_links, action_title = actions(), "View actions" if is_view else "Table actions" %}
+{% include "_action_menu.html" %}
{{ top_table() }}