themsaid / wink

A Laravel-based publishing platform
MIT License
2.85k stars 377 forks source link

How to add the SEO metadata? #302

Closed Jatapiaro closed 1 year ago

Jatapiaro commented 3 years ago

Hi, I'm planning to integrate this package into my Laravel project. But my biggest question so far, is, If I set the SEO metadata, how I can be sure it will be added to the webpage?

From the documentation I see that we should be only using {{$post->body}} or {{post->content}}, but that doesn't seems as a warranty of having the meta tags.

What should I do to place the meta tags in my view?

dircm commented 3 years ago

Hi @Jatapiaro the meta records are just attributes on the wink models. Have a look through the migrations to get an understanding of what is included. You can use attributes such as $post->title, $post->excerpt, $post->featured_image and $post->slug to get you started. Use these in blade templates or components to render the SEO meta content you need.

See the default post migration below :

Schema::create('wink_posts', function (Blueprint $table) { $table->uuid('id')->primary(); $table->string('slug')->unique(); $table->string('title'); $table->text('excerpt'); $table->text('body'); $table->boolean('published')->default(false); $table->dateTime('publish_date')->default('2018-10-10 00:00:00'); $table->string('featured_image')->nullable(); $table->string('featured_image_caption'); $table->uuid('author_id')->index(); $table->timestamps(); });

ArielMejiaDev commented 3 years ago

Hi @Jatapiaro as @dircm said you get from your Post model attributes like title, excerpt, featured_image, you can use those to built the cards for your social media platforms and other seo related, you can use a package like this: https://github.com/artesaos/seotools that its an excellent package it adds SEO meta tags for many things, to improve even more your SEO you can use a sitemap.xml file, here a package of spatie for this task: https://github.com/spatie/laravel-sitemap, hope some of this works for you.