tonyaldon / one.el

one.el a simple Static Site Generator for Emacs Lisp programmers and org-mode users.
https://one.tonyaldon.com
GNU General Public License v3.0
37 stars 12 forks source link

Add in the documentation how to create robots.txt and sitemap #6

Closed tanrax closed 8 months ago

tanrax commented 8 months ago

It's just a suggestion.

Add robots.txt

Make assets/robots.txt with this content:

User-Agent: *
Allow: /
Sitemap: https://domain.com/sitemap.txt

Add sitemap

You can create a simple sitemap in txt. Check this link

Only add in onerc.el

(defvar domain "example.com")

(defun make-sitemap (pages tree global)
  "Produce file ./public/sitemap.txt"
  (with-temp-file "./public/sitemap.txt"
    (insert
     (mapconcat 'identity (mapcar
               (lambda (page)
                 (let* ((path (plist-get page :one-path))
                    (link (concat "https://" domain path)))
                   link
                   ))
               pages) "\n"))))

(add-hook 'one-hook 'make-sitemap)
tonyaldon commented 8 months ago

Thanks @tanrax for the suggestion with code snippet.

I've just added it to the documentation in the 'Miscellaneous' section and also gives you the credit (I hope this is OK for you):

https://one.tonyaldon.com/docs/miscellaneous/

I just incoporated the https protocol in the domain variable, so that people can just change it for http if they need without changing make-sitemap function.