Skip to content

Commit 4643417

Browse files
committed
Update docs to guide users to avoid duplicate title tags when using Inertia Rails to manage meta on the server
1 parent c64ac77 commit 4643417

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

docs/cookbook/server-managed-meta-tags.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ Simply add the `inertia_meta_tags` helper to your layout. This will render the m
1717
<html>
1818
<head>
1919
...
20-
<%= inertia_meta_tags %> <!-- Add this inside your <head> tag -->
20+
<%= inertia_meta_tags %> <!-- Add this inside your <head> tag --> // [!code ++]
21+
<title inertia>My Inertia App</title> <!-- Remove existing title --> // [!code --]
2122
</head>
2223
</html>
2324
```
2425

2526
> [!NOTE]
26-
> If you have a `<title>` tag in your Rails layout, make sure it has the `inertia` attribute on it so Inertia knows it should deduplicate it. The Inertia Rails install generator does this for you automatically.
27+
> Make sure to remove the `<title>` tag in your Rails layout if you plan to manage it with Inertia Rails. Otherwise you will end up with duplicate `<title>` tags.
2728
2829
### Client Side
2930

@@ -314,13 +315,11 @@ class StoriesController < ApplicationController
314315
inertia_meta.add({ name: 'article:author', content: 'Tony Gilroy' })
315316
end
316317

317-
318318
# Renders a single article:author meta tag
319319
def single_author
320320
render inertia: 'Stories/Show'
321321
end
322322

323-
324323
# Renders multiple article:author meta tags
325324
def multiple_authors
326325
render inertia: 'Stories/Show', meta: [

lib/generators/inertia/install/install_generator.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def install_inertia
103103
before: '<%= vite_client_tag %>'
104104
end
105105

106-
gsub_file application_layout.to_s, /<title>/, '<title inertia>'
106+
gsub_file application_layout.to_s, /<title>/, '<title inertia>' unless svelte?
107107
else
108108
say_error 'Could not find the application layout file. Please add the following tags manually:', :red
109109
say_error '- <title>...</title>'

0 commit comments

Comments
 (0)