Closed tekknolagi closed 3 months ago
I see in the preview metadata, nikola is rendering <link rel="canonical" href="https://www.pypy.org/blog/">
, you would like it to point to https://bernsteinbear.com/blog/toy-abstract-interpretation ? I think that metadata value is created by our theme https://github.com/pypy/pypy.org/blob/fb39fe223cb192c77d60f10cd33996370418b045/themes/pypy/templates/base_helper.tmpl#L37
I am not sure how to adjust that per-post, maybe that line should move from the base_helper.tmpl
to the per-post template post.tmpl
around here,
and use a jinja-2 selector
{% if post.meta('canonical') %}
...
{% else %}
...
{% endif %}
Feel like giving it a try? You can build the docs locally with make
(if on macos, you will need gmake
from homebrew) and python<3.12. Then you should be able to inspect the generated posts for the correct links, I would expect the default to continue working.
Happy to make that change but was trying to avoid dropping canonical URLs from all your other pages
I'll go with that for now and if there's a way to add them back later, great
Thank you!
Maybe I wasn't clear. Each post page currently has a rel='canonical'
link element with the text <link rel="canonical" href="https://www.pypy.org/blog/">
. I think it would be desirable to allow canonical: xxx
in the post's metadata. If that metadata is not specified, the else
clause should create the pages exactly as it does today. If it is specified, the link in the xxx
should replace the href
target.
Oh no that was clear! I just worry that by moving it to the post template, the other types of pages (indices, etc) lose the canonical URL.
Ahh, good point. Maybe there is a better way?
@cfbolz decided to investigate
I think it would be desirable to allow
canonical: xxx
in the post's metadata. agreed, unfortunately what you suggested doesn't work :-(
I'm looking into it.
oh nice, good stuff
Looked at my post and others and they look good (canonical URL is correct). Awesome
TODO... figure out how to set canonical URL...