Emy
Emy

Reputation: 89

Vue.js Share page on fb via link

i need some help here. I'm developing a blog site, using vue-router so I have dynamic routes like this:

https:/myblog.com/post/a-post-title

I want to include sharing options, especially on facebook. For this, I need to modify the metadata dynamically for every post page. This includes displaying the post title, description and image on the facebook post preview box.

Doing a research I've found a vue plugin called vue-head allows you to modify the meta tags. It works fine but there's an issue. It seems that the facebook scraper analizes your SPA before any javascript magic happens, so I haven't found a way to make this work. And I can't find a way to pass custom params to the facebook sharing url, as it could be done before.

Also vue-meta plugin doesn't work, There is needed Pre-rendering on the page but prerender-spa-plugin doesn't work for dynamic routes like /post/:slug.

My application is front-end, and consumes data from the laravel api via axios.

So, does anyone know solution for this problem?

Upvotes: 2

Views: 1657

Answers (1)

Maksim Nesterenko
Maksim Nesterenko

Reputation: 6223

When you have an unlimited number of URLs that should be SEO-friendly, server-side rendering is the best choice.

If it's not an option or not something you can add quickly enough, you can try to prerender pages and serve static files, or even try doing prerendering on the fly for crawlers only.

There are tools that you can use for any project like prerender.io (github)

Upvotes: -1

Related Questions