diff --git a/app/views/wiki_pages/_sidebar.html.erb b/app/views/wiki_pages/_sidebar.html.erb
index f846b6300..3640570ab 100644
--- a/app/views/wiki_pages/_sidebar.html.erb
+++ b/app/views/wiki_pages/_sidebar.html.erb
@@ -2,19 +2,31 @@
<%= render "posts/partials/index/blacklist" %>
<%= render "wiki_pages/recent_changes" %>
- <% if @wiki_page.present? %>
+ <% if @wiki_page.present? && !@wiki_page.new_record? %>
Options
<% unless @wiki_page.is_meta_wiki? %>
- - <%= link_to "Tag History", tag_versions_path(search: { tag_id: @wiki_page.tag.id }) %>
- - <%= link_to "Post History", post_versions_path(search: { changed_tags: @wiki_page.title }) %>
+ <% if @wiki_page.tag.present? %>
+ - <%= link_to "Tag History", tag_versions_path(search: { tag_id: @wiki_page.tag&.id }) %>
+ <% end %>
+
+ <% if @wiki_page.title.present? %>
+ - <%= link_to "Post History", post_versions_path(search: { changed_tags: @wiki_page.title }) %>
+ <% end %>
<% end %>
- - <%= link_to "Wiki History", wiki_page_versions_path(search: { wiki_page_id: @wiki_page.id }) %>
- <% if Danbooru.config.forum_enabled?.to_s.truthy? %>
+
+ <% if @wiki_page.id.present? %>
+ - <%= link_to "Wiki History", wiki_page_versions_path(search: { wiki_page_id: @wiki_page.id }) %>
+ <% end %>
+
+ <% if Danbooru.config.forum_enabled?.to_s.truthy? && @wiki_page.title.present? %>
- <%= link_to "Discussions", forum_posts_path(search: { linked_to: @wiki_page.title }) %>
<% end %>
- - <%= link_to "What Links Here", wiki_pages_path(search: { linked_to: @wiki_page.title }) %>
+
+ <% if @wiki_page.title.present? %>
+ - <%= link_to "What Links Here", wiki_pages_path(search: { linked_to: @wiki_page.title }) %>
+ <% end %>
<% end %>
<% end %>
diff --git a/test/functional/wiki_pages_controller_test.rb b/test/functional/wiki_pages_controller_test.rb
index 3fdeb990b..7bd57cb2f 100644
--- a/test/functional/wiki_pages_controller_test.rb
+++ b/test/functional/wiki_pages_controller_test.rb
@@ -97,6 +97,14 @@ class WikiPagesControllerTest < ActionDispatch::IntegrationTest
assert_response :success
end
+ should "render for a wiki without a tag" do
+ @wiki_page = create(:wiki_page, title: "help:foo")
+ get wiki_page_path(@wiki_page)
+
+ assert(@wiki_page.tag.nil?)
+ assert_response :success
+ end
+
should "show the 'does not exist' page for a nonexistent title" do
get wiki_page_path("what")