Skip to content

This package helps you to add meta-tags, sitemap.xml and robots.txt into your project easily.

License

Notifications You must be signed in to change notification settings

EngincanV/SeoHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SeoHelper

CodeFactor NuGet

This package helps you to add meta-tags, sitemap.xml and robots.txt into your project easily.

Usage

  1. Install the package via Nuget.
Install-Package SeoHelper -Version 2.0.0

or

dotnet add package SeoHelper --version 2.0.0
  1. Add following service registrations to ConfigureServices method in Startup.cs.

Note: You can define your seo options (meta-tags, sitemap.xml and robots.txt) either specifying them in SeoOptions class or appsettings.json (under a section. E.g: SeoOptions or SeoConfigurations).

services.AddSeo(Configuration, sectionName: "SeoOptions");

If you want to specify your options via appsettings.json. You can create a section named whatever you want ("SeoOptions" in above usage) and specify it in the related service configuration method (AddSeo).

"SeoOptions": {
    "MetaTags": [
      { 
        "RelativeUrl": "/demo",
        "Title": "demo title",
        "Charset": "UTF-8",
        "MetaTagDescriptions": {
          "Author": "author",
          "Description": "description",
          "Keywords": "keywords"
        }
      },
      {
        "RelativeUrl": "/",
        "Title": "index title",
        "Charset": "UTF-8",
        "MetaTagDescriptions": {
          "author": "author",
          "description": "description"
        }
      }
    ],
    "Sitemap": {
      "Urls": [
        {
          "Url": "/article/1",
          "LastModificationDate": "12/12/2012"
        },
        {
          "Url": "/article/2",
          "LastModificationDate": "12/12/2012",
          "Priority": 1.0
        }
      ]
    },
    "RobotsTxt": {
      "DisplaySitemapUrl": true,
      "RobotsTxtSections": [
        {
          "UserAgent": "/google",
          "DisallowUrls": ["/account/manage", "/account/login"],
          "AllowUrls": ["/", "/home-page"]
        },
        {
          "UserAgent": "/yandex",
          "DisallowUrls": ["/account/manage", "/account/login"],
          "AllowUrls": ["*"]
        }
      ]
    },
    "OpenGraph": {
      "Twitter": {
        "Site": "@EngincanVeske",
        "Creator": "@EngincanVeske"
      },
      "Pages": [
        {
          "Url": "/",
          "OgTitle": "og-title",
          "OgType": "og-type",
          "OgImage": "og-image.jpg",
          "OgUrl": "og-url.com"
        },
        {
          "Url": "/demo",
          "OgTitle": "og-title2",
          "OgType": "og-typ2e",
          "OgImage": "og-image2.jpg",
          "OgUrl": "og-url2.com"
        }
      ]
    }
  },

You can configure your options like below in appsettings.json. With v2.0.0 now you can configure your open-graph and twitter card tags as well.

  1. Add following custom middleware to your Configure method in Startup.cs:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    //...
    app.UseSeoHelper();
    //...
}

If you encounter a problem, you can examine the sample (SeoHelper.Demo) in this repo.


Roadmap

  • Version 1
  • Meta-tags
  • Sitemap.xml
  • Robots.txt
  • Version 2
  • OpenGraph tags (for social media accounts)
  • Bug-fixes

About

This package helps you to add meta-tags, sitemap.xml and robots.txt into your project easily.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages