sitemaps

1. sitemaps.org - Home

<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <url>
      <loc>http://www.example.com/</loc>
      <lastmod>2005-01-01</lastmod>
      <changefreq>monthly</changefreq>
      <priority>0.8</priority>
   </url>
</urlset>

2. sitemap 생성

(defun templated-html-create-sitemap-xml (output directory base-url &rest regexp)
  "https://www.sitemaps.org/protocol.html"
  (let* ((rx (or regexp "\\.html$")))
    (with-temp-file output
      (insert "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<urlset
      xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"
      xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
      xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9
      http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n")
      (insert
       (format
        "<url>\n <loc>%s</loc>\n <priority>1.00</priority>\n</url>\n"
        base-url))

      (cl-loop for file in (directory-files-recursively directory rx)
               do (insert
                   (format
                    "<url>\n <loc>%s/%s</loc>\n <lastmod>%s</lastmod>\n <priority>%s</priority>\n</url>\n"
                    base-url (file-relative-name file directory)
                    (format-time-string "%Y-%m-%d" (file-attribute-status-change-time (file-attributes file)))
                    (if (s-equals? (f-base file) "index") "0.75" "0.5"))))
      (insert "</urlset>"))))

(defun make-sitemap ()
  (templated-html-create-sitemap-xml
   "~/org/dist/public_html/sitemap.xml"
   "~/org/dist/public_html"
   "https://7696122.github.io"))

;; (make-sitemap)

3. Ref