diff --git a/CHANGELOG b/CHANGELOG
index 01940f71d7bb1f4d4a4764220a90f774eefadec6..4ed592b580f8e3f8a01f99502d0da50cc82c6ffb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,9 @@ v 8.12.0 (unreleased)
   - Change merge_error column from string to text type
   - Optimistic locking for Issues and Merge Requests (title and description overriding prevention)
 
+v 8.11.1 (unreleased)
+  - Fix file links on project page when default view is Files !5933
+
 v 8.11.0
   - Use test coverage value from the latest successful pipeline in badge. !5862
   - Add test coverage report badge. !5708
@@ -200,8 +203,6 @@ v 8.10.3
   - Trim extra displayed carriage returns in diffs and files with CRLFs. !5588
   - Fix label already exist error message in the right sidebar.
 
-v 8.10.3 (unreleased)
-
 v 8.10.2
   - User can now search branches by name. !5144
   - Page is now properly rendered after committing the first file and creating the first branch. !5399
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index fc52cd2f367f2e629d97985882799c3f9b748d4a..2a6385c1029514ef981ec8cdbb5776b0ecec6da9 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -5,7 +5,7 @@ class ProjectsController < Projects::ApplicationController
   before_action :project, except: [:new, :create]
   before_action :repository, except: [:new, :create]
   before_action :assign_ref_vars, only: [:show], if: :repo_exists?
-  before_action :tree, only: [:show], if: [:repo_exists?, :project_view_files?]
+  before_action :assign_tree_vars, only: [:show], if: [:repo_exists?, :project_view_files?]
 
   # Authorize
   before_action :authorize_admin_project!, only: [:edit, :update, :housekeeping, :download_export, :export, :remove_export, :generate_new_export]
@@ -332,4 +332,11 @@ class ProjectsController < Projects::ApplicationController
   def get_id
     project.repository.root_ref
   end
+
+  # ExtractsPath will set @id = project.path on the show route, but it has to be the
+  # branch name for the tree view to work correctly.
+  def assign_tree_vars
+    @id = get_id
+    tree
+  end
 end
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
index 1b14c66fe286ec30fa059e7773f2d6c34667235e..e00d85904d5da844cd41b7c5730f22ad1293404d 100644
--- a/spec/features/projects_spec.rb
+++ b/spec/features/projects_spec.rb
@@ -115,6 +115,35 @@ feature 'Project', feature: true do
     end
   end
 
+  describe 'tree view (default view is set to Files)' do
+    let(:user) { create(:user, project_view: 'files') }
+    let(:project) { create(:forked_project_with_submodules) }
+
+    before do
+      project.team << [user, :master]
+      login_as user
+      visit namespace_project_path(project.namespace, project)
+    end
+
+    it 'has working links to files' do
+      click_link('PROCESS.md')
+
+      expect(page.status_code).to eq(200)
+    end
+
+    it 'has working links to directories' do
+      click_link('encoding')
+
+      expect(page.status_code).to eq(200)
+    end
+
+    it 'has working links to submodules' do
+      click_link('645f6c4c')
+
+      expect(page.status_code).to eq(200)
+    end
+  end
+
   def remove_with_confirm(button_text, confirm_with)
     click_button button_text
     fill_in 'confirm_name_input', with: confirm_with