Comments (16)
Hey there! Thanks for your interest in Inertia. From the readme:
Accessing data in root template
There are situations where you may want to access your prop data in your root Blade template. For example, you may want to add a meta description tag, Twitter card meta tags, or Facebook Open Graph meta tags. These props are available via the $page
variable.
<meta name="twitter:title" content="{{ $page['props']['event']->title }}">
Sometimes you may even want to provide data that will not be sent to your JavaScript component. You can do this using the withViewData()
method.
return Inertia::render('Event', ['event' => $event])->withViewData(['meta' => $event->meta]);
You can then access this variable like a regular Blade variable.
<meta name="description" content="{{ $meta }}">
from inertia-laravel.
@connecteev All good! Glad you got the answers you needed. 💪
from inertia-laravel.
Totally, we mention this in the docs here: https://inertiajs.com/server-side-rendering 👍
from inertia-laravel.
This will be rendered server-side
If you use inertia-link to let users navigate around at frontend, you may also need to do this:
This would be very helpful
from inertia-laravel.
I published the implementation details here
Thanks, I'll read it in incognito mode. I'm out of free stories
from inertia-laravel.
following this thread.
What about if we want to use a $page.props as a title? just an example:
metaInfo: { title: this.meta_title },
always return an undefined data.
I'm using a prop to manage translations for the title.
cc @reinink
from inertia-laravel.
Thanks @reinink I'm a bit confused by this response ^^^ and the one you replied to a few days ago over email (below). There you said:
If SEO is important, than Inertia.js probably isn't the right choice. Inertia.js is more intended for web apps and admin control panels where SEO isn't an issue.
Inertia.js is different than Nuxt in that you don't need to create an API. You simply have one code base, with controllers and server-side routing. However, the big win is that Inertia.js allows you to build an entirely JavaScript based SPA front-end.
I think if I was building an app that had SEO concerns, I'd probably just stick with Blade views, and then drop in Vue components where extra functionality is needed.
Zooming out a bit, I keep coming back to, can Inertiajs be used for SSR? Can I ditch Nuxt -> Laravel APIs and just go with InertiaJs+Laravel? SEO is hugely important for my app....and if I can get away with a pure Laravel approach, Intertiajs would simplify my tech stack if it can support SSR.
from inertia-laravel.
Which parts of what I said are you confused about?
I feel like I am being pretty clear that Inertia doesn't do SSR right now, and that if SEO is a concern for you, it may not be the right choice, at this time.
Yes, it would be great if it did SSR out of the box, but that's going to take time and effort to research, test and implement. It's on our long-term roadmap to look at more closely, but it isn't a priority for the framework at this time.
My answer above specifically just shows you how to set meta tags. However, that still doesn't make it SEO-friendly. The content is still all within JavaScript, which search engines may, or may not read properly.
Sorry I cannot be more helpful. 🤷♂
from inertia-laravel.
@reinink Sorry, I didn't mean to come off as complain-y or ungrateful!
Thanks for your detailed responses and thanks for the work you are doing. It means a lot...I was just genuinely confused, but your last answer clarifies it and makes it crystal!
I do need SSR so I (unfortunately) can't use inertia right now. If that roadmap changes, you can color me VERY interested. In the meantime, thanks again...and inertia will be my top choice for a SPA app!
from inertia-laravel.
I know the issue is closed, but I came across this service that I know might help in SEO of inertia apps.
Prerendering
This is can be achieved by using middleware in your application that tells if the user is real of a web crawler like Google bot. If it is a crawler, we send it the pre-rendered HTML for Easy SEO.
Check it out this service prerender.io.
I hope it helps someone
from inertia-laravel.
@reinink , My bad I had forgotten about that part of the docs. Thank you for your support and good work
from inertia-laravel.
Suggestion:
You may try the combination of butschster/meta-tags and vue-meta package.
vue-meta
will handle the meta info changes when user navigating at frontend dynamically.
butschster/meta-tags
will help on SEO when crawlers crawl your website.
from inertia-laravel.
Suggestion:
You may try the combination of butschster/meta-tags and vue-meta package.
vue-meta
will handle the meta info changes when user navigating at frontend dynamically.
butschster/meta-tags
will help on SEO when crawlers crawl your website.
How would that work 🤔. Do you have some kind of demo?
I still think that inertia is not for you if you care much about SEO. I use it in Dashboards.
from inertia-laravel.
This will be rendered server-side
If you use inertia-link to let users navigate around at frontend, you may also need to do this:
from inertia-laravel.
I published the implementation details here
from inertia-laravel.
A new approach to use with <Head>
https://luiyongsheng.medium.com/laravel-inertiajs-seo-workaround-late-2021-a1356bed6d29
from inertia-laravel.
Related Issues (20)
- Laravel/VueJs XSRF/CSRF token rename is not working correctly using the useForm() functionality. HOT 2
- Path to the VUE component outside the module HOT 1
- Connecting to an external host using NodeJS HOT 1
- Add support for bun in `php artisan inertia:start-ssr` HOT 1
- Laravel, Vue 3, SSR and font awesome icons HOT 3
- Laravel redirect response not working HOT 1
- Redirect Back issue HOT 1
- Validate multi step form - with Interia or Axios? HOT 1
- SSR dont work
- inertia laravel opens the page in a new modal HOT 1
- Multiple definitions exist for class 'Route'
- Browser cache controlling
- Data management on the Client Side
- Show toast or message after request complete. HOT 2
- Cant get validation working on laravel-inertia-vue HOT 2
- Login not working with Laravel + Inertia + React HOT 1
- problem in running ssr when using vue vite and ziggy
- Add dinamic parameters to Inertia::lazyLoad props HOT 1
- SSR with Dynamically Shared Props HOT 1
- Providing empty object to the view
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from inertia-laravel.