cryogen-project / cryogen

A simple static site generator written in Clojure
http://cryogenweb.org/
Eclipse Public License 1.0
1.09k stars 96 forks source link

The `/blog/blog/` problem #259

Closed simon-brooke closed 1 year ago

simon-brooke commented 1 year ago

I'm not suggesting this is a bug in Cryogen (for which many thanks, by the way; it's an excellent tool); it may be a bug I've introduced through misunderstanding.

If it is a problem other users are experiencing I will try to create a fix and submit a pull request, if that's acceptable.

The problem is that I'm getting the path element /blog/ both appended to :site-url and prepended to :uri, so that, for example,

    <link rel="canonical" href="{{site-url}}{{uri}}">

(in themes/blue/html/base.html) is expanded as

    <link rel="canonical" href="https://www.journeyman.cc/blog/blog/posts-output/2023-05-03_on-the-protection-of-minorities/">

Now: I've created my own theme which is a heavily hacked version of the standard blue theme, but I haven't hacked any of the Clojure code at all (yet); and the /blog/blog/ problem is present even if I switch back to the standard blue theme, so if this is my problem it's not one I have introduced in my theme.

The other possibility is that I've misconfigured my config.edn, which I'll attach; but the possibly-significant bindings are:

{
 :blog-prefix                  "/blog"
 :site-url                     "https://www.journeyman.cc/blog/"
}

(ah, OK, GitHub doesn't accept EDN as an upload format! The following is the whole content of my config.edn)

{:archive-group-format         "yyyy MMMM"
 :author                       "Simon Brooke"
 :author-root-uri              "authors-output"
 :blocks-per-preview           2
 :blog-prefix                  "/blog"
 :clean-urls                   :trailing-slash
 :collapse-subdirs?            false
 :debug?                       false
 :disqus?                      false
 :description                  "Random thoughts on politics, fiction and software; occasionally interesting."
 :description-include-elements #{:p :h1 :h2 :h3 :h4 :h5 :h6}
 :disqus-shortname             ""
 :hide-future-posts?           true
 :ignored-files                [#"\.#.*" #".*\.swp$"]
 :keep-files                   [".git"]
 :klipse                       {:settings {:selector ".klipse-cljs"}}
 :post-date-format             "yyyy-MM-dd"
 :page-root                    "pages"
 :page-root-uri                "pages-output"
 :post-root                    "posts"
 :post-root-uri                "posts-output"
 :posts-per-page               5
 :previews?                    false
 :public-dest                  "public"
 :resources                    ["img"]
 :rss-filters                  ["cryogen"]
 :rss-name                     "feed.xml"
 :recent-posts                 3
 :sass-path                    "sass"
 :sass-src                     []
 :site-title                   "The Fool on the Hill"
 :site-url                     "https://www.journeyman.cc/blog/"
 :tag-root-uri                 "tags-output"
 :theme                        "green"}
lacarmen commented 1 year ago

I believe the issue is that you've got "/blog" in both your :site-url and your :blog-prefix. Remove it from the :site-url key and that should fix your problem 😊

simon-brooke commented 1 year ago

Ta!

simon-brooke commented 1 year ago

Yes, can confirm this works. D'oh!