jk.nipponalba.scot website https://jk.nipponalba.scot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

70 lines
2.9 KiB

  1. *This is not a standalone theme. This is a Hugo theme component.*
  2. To enable ATOM feeds for your site:
  3. 1. Clone this repo to ~<your-site-dir>/themes/hugo-atom-feed~ directory.
  4. 2. Add these your site's ~config.toml~:
  5. - Add "hugo-atom-feed" as the *left-most element* of the ~theme~
  6. list variable. For example:
  7. #+begin_src toml
  8. theme = ["hugo-atom-feed", "my-theme"]
  9. #+end_src
  10. - Add "ATOM" to all the Page Kinds for which you want to create
  11. ATOM feeds:
  12. #+begin_src toml
  13. [outputs]
  14. # <domain>/atom.xml
  15. home = ["HTML", "RSS", "ATOM"] # default = ["HTML", "RSS"]
  16. # <domain>/posts/atom.xml
  17. section = ["HTML", "RSS", "ATOM"] # default = ["HTML", "RSS"]
  18. # <domain>/tags/mytag/atom.xml, <domain>/categories/mycat/atom.xml
  19. taxonomy = ["HTML", "RSS", "ATOM"] # default = ["HTML", "RSS"]
  20. #+end_src
  21. * Selectively excluding pages from the feed
  22. For the pages that you would like to exclude from the feed, set the
  23. ~disable_feed~ parameter in its front-matter to ~true~.
  24. #+begin_src toml
  25. disable_feed = true
  26. #+end_src
  27. * Pay attention to web server MIME type
  28. To fully comply with web standards, make sure your web server will
  29. send the correct [[https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Type][/Content-Type/ HTTP response header]] for the feed file
  30. name ~atom.xml~. The correct response header looks like this:
  31. #+begin_example
  32. Content-Type: application/atom+xml; charset=UTF-8
  33. #+end_example
  34. Note that even though the feed file extension is ~.xml~, the [[https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types][MIME type]]
  35. here is slightly adjusted from ~application/xml~ to
  36. ~application/atom+xml~.
  37. While this might not be important for many feed readers, it could
  38. still be a source of error. So it is a good idea to play safe. How
  39. you could achieve this depends on the type of web server software you
  40. are running your website on.
  41. ** Specifying the correct ~Content-Type~ for Netlify
  42. You can specify the /Content-Type/ of ~atom.*~ and ~*.atom~ files to
  43. be ~application/atom+xml; charset=UTF-8~ using the below in your site's
  44. ~netlify.toml~:
  45. #+begin_src toml
  46. [[headers]]
  47. for = "atom.*"
  48. [headers.values]
  49. Content-Type = "application/atom+xml; charset=UTF-8"
  50. [[headers]]
  51. for = "*.atom"
  52. [headers.values]
  53. Content-Type = "application/atom+xml; charset=UTF-8"
  54. #+end_src
  55. *** References
  56. - [[https://www.netlify.com/docs/headers-and-basic-auth/]]
  57. - [[https://www.netlify.com/blog/2017/10/17/introducing-structured-redirects-and-headers/]]
  58. ** Note about Google Chrome
  59. Note that Google Chrome currently still [[https://bugs.chromium.org/p/chromium/issues/detail?id=84][features a bug]] for such MIME
  60. types so that automatic XML rendering is not performed. You may
  61. decide what is more important for you: watching the rendered source in
  62. your browser once in a while, or maximum feed reader compatibility 😉.