Add <link rel="sitemap" ...> to head.

This commit is contained in:
Dillon Kearns 2020-01-25 15:24:51 -08:00
parent e2f498aa87
commit 4ba9fe6434
3 changed files with 32 additions and 5 deletions

View File

@ -487,6 +487,7 @@ highlightableLink currentPath linkDirectory displayName =
commonHeadTags : List (Head.Tag Pages.PathKey)
commonHeadTags =
[ Head.rssLink "/blog/feed.xml"
, Head.sitemapLink "/sitemap.xml"
]

View File

@ -9,6 +9,11 @@ in search results.
Be sure to exclude pages from your site map that you don't want to be indexed. This is a good resource
that explains which pages should be included and which should be excluded: <https://blog.spotibo.com/sitemap-guide/#which-urls-should-be-put-in-a-sitemap>.
It's important that you not include duplicate pages in your sitemap as this can result in a serious SEO penalty or
flag your site as spam.
Here's another reference with more best practices: <https://support.google.com/webmasters/answer/183668?hl=en>
-}
import Date exposing (Date)

View File

@ -1,9 +1,9 @@
module Head exposing
( Tag, metaName, metaProperty
, rssLink, sitemapLink
, AttributeValue
, currentPageFullUrl, fullImageUrl, fullPageUrl, raw
, toJson, canonicalLink
, rssLink
)
{-| This module contains low-level functions for building up
@ -16,6 +16,7 @@ But this module might be useful if you have a special use case, or if you are
writing a plugin package to extend `elm-pages`.
@docs Tag, metaName, metaProperty
@docs rssLink, sitemapLink
## `AttributeValue`s
@ -109,14 +110,14 @@ canonicalLink maybePath =
{-| Add a link to the site's RSS feed.
```html
<link rel="alternate" type="application/rss+xml" href="/rss.xml">
```
Example:
rssLink "/feed.xml"
```html
<link rel="alternate" type="application/rss+xml" href="/rss.xml">
```
-}
rssLink : String -> Tag pathKey
rssLink url =
@ -127,6 +128,26 @@ rssLink url =
]
{-| Add a link to the site's RSS feed.
Example:
sitemapLink "/feed.xml"
```html
<link rel="sitemap" type="application/xml" href="/sitemap.xml">
```
-}
sitemapLink : String -> Tag pathKey
sitemapLink url =
node "link"
[ ( "rel", raw "sitemap" )
, ( "type", raw "application/xml" )
, ( "href", raw url )
]
{-| Example:
Head.metaProperty "fb:app_id" (Head.raw "123456789")