NAME

App::Dapper::Publish - Sitemaps, feeds, Markdown copies, llms.txt and SEO tags.

DESCRIPTION

After the pages of a site are rendered, Dapper writes files that help search engines, feed readers and AI tools find and read them. Each is controlled by a setting in _config.yml:

url: https://example.com   # needed for absolute links in all of these
markdown_twins: true       # page.md next to each Markdown page's HTML
llms_txt: true             # /llms.txt and /llms-full.txt
sitemap: true              # /sitemap.xml
feed:                      # /feed.xml (off unless set)
  category: blog
  limit: 20

Redirects (redirects in _config.yml, or _data/redirects.yml) are written as small pages at the old URLs.

It also builds page.seo, the tags a layout can put in its <head>: a description, a canonical link, Open Graph and Twitter tags, a feed link, and JSON-LD structured data.

absolute_url

Takes the site and a URL relative to the site root (e.g. /about/) and returns it with site.url in front, or unchanged if site.url is not set or the URL is already absolute.

plain_text

Takes HTML and returns its text: tags removed, common entities decoded and white space collapsed.

description

Takes a page and returns its description: its description setting, or the text of its excerpt, shortened to about 200 characters.

is_html

Returns true if a page's output is an HTML file.

enabled

Takes the site and the name of a setting, and returns true unless the setting is off (false, 0, "false" or "no").

is_draft

Returns true if a page's front matter says it is a draft (draft: true).

twin_path

Takes a page and returns the output path of its Markdown copy: blog/post/index.html becomes blog/post/index.md.

twin_url

Takes a page and returns the URL of its Markdown copy: /blog/post/ becomes /blog/post/index.md.

has_twin

Returns true if a page gets a Markdown copy: it is an HTML page made from a Markdown file, it has not turned it off (markdown_twin: false), and its Markdown is not a template (which would show template code, not text).

twin

Takes the site and a page, and returns the text of its Markdown copy: the title as a heading, the description as a quote, and the page's Markdown.

llms_txt

Takes the site and the pages that have Markdown copies, and returns the text of /llms.txt: the site's name and description, then a list of links to the Markdown copies, grouped by category (newest first), with other pages last.

llms_full_txt

Takes the site and the pages that have Markdown copies, and returns the text of /llms-full.txt: every Markdown copy, one after another, each with its URL.

sitemap

Takes the site and its pages, and returns the text of /sitemap.xml, listing every HTML page that has not turned it off with sitemap: false. Needs site.url.

feed_settings

Takes the site and returns the feed settings (path, category, limit, title) if a feed is turned on, or nothing if it is not. feed: true turns on a feed of every page with a category.

feed_pages

Takes the site and the feed settings, and returns the pages in the feed: those in the feed's category (or with any category), newest first, up to the limit.

feed

Takes the site, the feed settings and the pages in the feed, and returns an Atom feed.

redirects

Takes the site and returns a hash of old URLs to new ones, from redirects in _config.yml and the _data/redirects.yml data file (which wins). Dies if an entry isn't a pair of URLs.

redirect_path

Takes an old URL and returns the path of the file to write for it: /old/ becomes old/index.html, /old.html stays old.html, and /old becomes old/index.html.

redirect_page

Takes the site and the URL to send people to, and returns a small HTML page that sends browsers (and search engines) there.

seo

Takes the site and a page, and returns the HTML for page.seo: tags for the page's <head>.