Fornax.Seo 1.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Fornax.Seo --version 1.1.1                
NuGet\Install-Package Fornax.Seo -Version 1.1.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Fornax.Seo" Version="1.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Fornax.Seo --version 1.1.1                
#r "nuget: Fornax.Seo, 1.1.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Fornax.Seo as a Cake Addin
#addin nuget:?package=Fornax.Seo&version=1.1.1

// Install Fornax.Seo as a Cake Tool
#tool nuget:?package=Fornax.Seo&version=1.1.1                

Fornax.Seo

Nuget version NuGet workflow status Test workflow status

A SEO meta tag generator for Fornax

Goals

  • enhance the search engine visibility of Fornax-generated websites with:

  • try to enforce some SEO best practises, e.g. requiring absolute URLs to all content items

Usage example

NOTE

The following requires fornax 0.14.0 or newer. Visit the wiki to learn how to use this package with earlier fornax versions.

  • Change into a project directory and scaffold a new website

    fornax new
    

IMPORTANT

  • Provide the root domain of your website:

    // loaders/globalloader.fsx
    #r "../_lib/Fornax.Core.dll"
    
    type SiteInfo = {
        title: string
        /// The root domain of your website - must be an absolute URL
        baseUrl: string
        description: string
    }
    
  • Add personal authorship details, e.g.:

    // loaders/globalloader.fsx
    #r "nuget: Fornax.Seo"
    
    open Fornax.Seo
    
    let loader (projectRoot: string) (siteContent: SiteContents) =
        let siteInfo =
            { title = "Sample Fornax blog"
              baseUrl = "http://example.com"
              description = "Just a simple blog" }
    
        let onTheWeb =
            [ "linkedin.com/in/username"
              "github.com/username"
              "bitbucket.org/username"
              "facebook.com/username" ]
    
        let siteAuthor: ContentCreator =
            { Name = "Moi-même"
              Email = "info@example.com"
              SocialMedia = onTheWeb }
    
        siteContent.Add(siteInfo)
        siteContent.Add(siteAuthor)
    
        siteContent
    

Collect metadata from a content item (e.g., a blog posting)

// generators/post.fsx
#r "../_lib/Fornax.Core.dll"
#r "nuget: Fornax.Seo"
#load "layout.fsx"

open Html
open Fornax.Seo

let generate' (ctx: SiteContents) (page: string) =
    let siteInfo = ctx.TryGetValue<Globalloader.SiteInfo>()
    let siteName = siteInfo |> Option.map (fun si -> si.title)

    let tagline =
        siteInfo
        |> Option.map (fun si -> si.description)
        |> Option.defaultValue ""

    let siteAuthor =
        ctx.TryGetValue<ContentCreator>()
        |> Option.defaultValue ContentCreator.Default

    let siteRoot =
        siteInfo
        |> Option.map (fun si -> si.baseUrl)
        |> Option.defaultValue ContentObject.Default.BaseUrl

    let post =
        ctx.TryGetValues<Postloader.Post>()
        |> Option.defaultValue Seq.empty
        |> Seq.find (fun p -> p.file = page)

    let postMeta: ContentObject =
        { Title = post.title
          BaseUrl = siteRoot
          Url = post.file.Replace(System.IO.Path.GetExtension post.file, ".html")
          Description = tagline
          Author = { siteAuthor with Name = defaultArg post.author siteAuthor.Name }
          SiteName = siteName
          Headline = Some post.summary
          ObjectType = Some "Blog"
          ContentType = Some "BlogPosting"
          OpenGraphType = Some "article"
          Locale = Some "en-us"
          Published = post.published
          Modified = post.modified
          Tags = Some post.tags
          Meta =
              Some [ ("Image", defaultArg post.image $"{siteRoot}/images/avatar.jpg")
                     ("Publisher", defaultArg siteName siteAuthor.Name) ] }

    ctx.Add(postMeta)
    // . . .

Render SEO metadata in your page layout

// generators/layout.fsx
#r "../_lib/Fornax.Core.dll"
#r "nuget: Fornax.Seo"

open Html
open Fornax.Seo

// . . .

let layout (ctx: SiteContents) (active: string) (content: HtmlElement seq) =
    let siteAuthor =
        ctx.TryGetValue<ContentCreator>()
        |> Option.defaultValue ContentCreator.Default

    let seoData =
        ctx.TryGetValues<ContentObject>()
        |> Option.defaultValue Seq.empty

    let pageMeta =
        seoData
        |> Seq.tryFind (fun p -> p.Title.Contains(active))
        |> function
        | Some info -> info
        | _ -> { ContentObject.Default with Author = siteAuthor }

    html [] [
        head [] [
            meta [ CharSet "utf-8" ]
            meta [ Name "viewport"; Content "width=device-width, initial-scale=1" ]
            // . . .
            yield! seo pageMeta
        ]
        body [] [
            // . . .
            footer [] [ yield! socialMedia siteAuthor ]
        ]
    ]

    // . . .

Similar NuGet libraries (by framework)

.NET

ASP.NET

Umbraco

Contributing

A guide to building the project and making pull requests can be found here.

License

Distributed under the terms of the Mozilla Public License Version 2.0.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.1 114 8/26/2024
1.3.0 141 2/28/2024
1.2.0 249 3/14/2023
1.1.1 285 12/18/2022
1.1.0 427 5/28/2022
1.0.0 394 8/15/2021
0.1.1 315 7/8/2021
0.1.0 333 4/30/2021

- Bump FSharp.Data to 4.2.10
- Bump Newtonsoft.Json to 13.0.2
- Serialize JSON-LD `@context` property as a simple string
- Use a shorter timestamp format in JSON-LD and OpenGraph fields
- Make social media link titles more readable