pypy / pypy.org

Sources for website at https://www.pypy.org
34 stars 11 forks source link

Cross-post toy abstract interpreter blog post #125

Closed tekknolagi closed 3 months ago

tekknolagi commented 3 months ago

TODO... figure out how to set canonical URL...

mattip commented 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.

tekknolagi commented 3 months ago

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!

mattip commented 3 months ago

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.

tekknolagi commented 3 months ago

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.

mattip commented 3 months ago

Ahh, good point. Maybe there is a better way?

tekknolagi commented 3 months ago

@cfbolz decided to investigate

cfbolz commented 3 months ago

I think it would be desirable to allow canonical: xxx in the post's metadata. agreed, unfortunately what you suggested doesn't work :-(

cfbolz commented 3 months ago

I'm looking into it.

tekknolagi commented 3 months ago

oh nice, good stuff

tekknolagi commented 3 months ago

Looked at my post and others and they look good (canonical URL is correct). Awesome