• Stars
    star
    106
  • Rank 325,871 (Top 7 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 6 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ”Œ Generate SEO friendly meta header for every page

Vuepress Plugin SEO

πŸ”Œ Generate SEO friendly meta header for every page

Installation

npm i vuepress-plugin-seo -D

Usage

plugins: {
    'seo': { /* options */ }
},

Note that Vuepress allows multiple syntaxes to register plugins. See Vuepress documentation on how to use a plugin for more information.

Options

The default options below show you how the relevant data is being retrieved from your vuepress application and its pages. Simply override the function of your choice to define your own logic.

// Options
{
    siteTitle: (_, $site) => $site.title,
    title: $page => $page.title,
    description: $page => $page.frontmatter.description,
    author: (_, $site) => $site.themeConfig.author,
    tags: $page => $page.frontmatter.tags,
    twitterCard: _ => 'summary_large_image',
    type: $page => ['articles', 'posts', 'blog'].some(folder => $page.regularPath.startsWith('/' + folder)) ? 'article' : 'website',
    url: (_, $site, path) => ($site.themeConfig.domain || '') + path,
    image: ($page, $site) => $page.frontmatter.image && (($site.themeConfig.domain && !$page.frontmatter.image.startsWith('http') || '') + $page.frontmatter.image),
    publishedAt: $page => $page.frontmatter.date && new Date($page.frontmatter.date),
    modifiedAt: $page => $page.lastUpdated && new Date($page.lastUpdated),
}

A few things to note:

  • Each of those functions take three agurments: $page (page configs provided by Vuepress), $site (site configs provided by Vuepress) and path (the built permalink of the page which is different than $page.path in the plugin world).
  • If the return value of any of these options is null or undefined, it will not add the metadata. This avoids having lots of empty meta header in your pages.
  • The author option should be an object with any of the following values: name (the full name of the author) and twitter (the Twitter handle of the author, e.g. @lorismatic).
  • The tags option should be an array.
  • The type should be part of the Open Graph protocol. E.g. article, profile, book, website.
  • Both the url and image options try to use the $site.themeConfig.domain variable as a prefix. If it's not available, it will still work but the links of your meta headers will be relative and not absolute.
  • When defining the image attribute in your frontmatter, you should make sure that its path is already resolved. That means, either storing your SEO images in the public folder or simply copy/pasting the path of a resolved image from the browser, e.g. /assets/img/my_image.8b54ab32.jpg. You cannot use for example image: ./my_image.jpg to reference the image in the current folder. We cannot resolve this path for you at this time because vuepress does not support asset resolution in frontmatter.
  • It can be wise to include a timezone when defining publishedAt in your frontmatter. E.g. date: 2018-06-07 23:46 UTC.
  • The modifiedAt default value will work out-of-the-box if you registers the @vuepress/last-updated plugin before this one.

Finally you can also add your own custom meta headers through the customMeta option:

// Options
{
    //...
    customMeta: (add, context) => {

        const {
            $site, // Site configs provided by Vuepress
            $page, // Page configs provided by Vuepress

            // All the computed options from above:
            siteTitle, title, description, author, tags,
            twitterCard, type, url, image, publishedAt, modifiedAt,
        } = context

        add('twitter:site', $site.themeConfig.twitter)
        // -> <meta name="twitter:site" content="@github"></meta>

        add('book:isbn', '9780091929114', 'property')
        // -> <meta property="book:isbn" content="9780091929114"></meta>
    },
}

Note that customMeta defaults to () => {}.

More Repositories

1

laravel-actions

⚑️ Laravel components that take care of one specific task
PHP
2,449
star
2

laravel-deployer

πŸš€ Zero-downtime deployment out-of-the-box
PHP
1,666
star
3

laravel-docker

🐳 Generic docker image for Laravel Applications
Dockerfile
931
star
4

laravel-search-string

πŸ” Generates database queries based on one unique string
PHP
770
star
5

tailwindcss-plugins

πŸ”ŒπŸŒŠ Set of useful plugins for tailwindcss
JavaScript
284
star
6

cron-translator

⏰️ Makes CRON expressions human-readable
PHP
281
star
7

javel

🎁 Simple, lightweight and customisable Laravel models in your JavaScript
JavaScript
277
star
8

artisan-ui

🧰 Run your artisan commands by pressing buttons
Blade
217
star
9

solana-twitter

Simple tweets as Solana accounts
Vue
201
star
10

solana-wallets-vue

Solana wallet integration for Vue 3
TypeScript
161
star
11

lody

πŸ—„ Load files and classes as lazy collections in Laravel.
PHP
88
star
12

blog-google-calendar

🌐 Google Calendar Integration
PHP
49
star
13

vue-lab

πŸ‘¨β€πŸ”¬ Collection of reusable Vue.js goodies
Vue
45
star
14

laravel-add-select

🧱 Add your subSelect queries the Laravel way
PHP
33
star
15

blog-2019-vuepress

✍️ Personal website and blog (2019 edition)
Vue
30
star
16

vuepress-plugin-disqus

πŸ”Œ Register a global Disqus component to add to your layouts
JavaScript
29
star
17

request-controller

Use FormRequests as invokable controllers
PHP
28
star
18

dotfiles

❄️ Personal set of configurations for macOS
Shell
26
star
19

paparazzi

πŸ“Έ Code base for the Single-Page Laravel course
PHP
16
star
20

kanuu-getting-started

Add billing to your app in 5 minutes with Paddle and Kanuu
PHP
12
star
21

solana-vue3-counter

A test repo for getting started with Anchor and Vue3
JavaScript
9
star
22

peppermint

[WIP] Metaplex SDK Mint example
Vue
7
star
23

enchant

πŸ§™β€β™‚οΈ Auto-generated Laravel documentations [WIP]
PHP
7
star
24

minecravel

Just having fun with Minecraft mods (something Laravel related perhaps...)
Java
6
star
25

postpone

πŸ¦₯ Handle asynchronous JS pipelines
TypeScript
5
star
26

learn-laravel-deployer

πŸ‘¨β€πŸ« Dummy Laravel app used in the "Getting started with Laravel Deployer" video series
PHP
4
star
27

solana-core-programs

[WIP] Generated clients for core Solana programs
Rust
4
star
28

laravel-actions-docs

πŸ“š Documentation for Laravel Actions
JavaScript
3
star
29

solana-trustpilot

A Umi/Kinobi demo
TypeScript
3
star
30

lab-deployer

Testing the deployment of a Laravel app with Deployer7
PHP
2
star
31

typedoc-plugin-expand-object-like-types

Expands TS definitions for object-like types
JavaScript
2
star
32

fail-fast-ci-tests

A GitHub Actions playground to figure out the best fail-fast strategy
2
star
33

js-next-cra-5

[WIP] Testing the Metaplex JS SDK on CRA 5
JavaScript
1
star
34

token-recipes

TypeScript
1
star
35

kinobi-template

Archived in favour of https://github.com/solana-program/create-solana-program
TypeScript
1
star