On Sun, 21 Jun 2020 at 16:18, Graeme Pietersz <graeme.piete...@gmail.com> wrote:
>
> I want some blog posts to appear on two Nikola sites.
>
> I would prefer not to link from one site to the other, but to duplicate the 
> posts on the two sites.
>
> I would therefore like to use a canonical tag to let search engines know 
> which to treat as the original.
>
> I tried the link metadata field but it seems to have no effect.
>
> I can see there are entry points to add to templates, but I want to replace 
> something that is already there.
>
> The alternative seems to be to create a child theme and override the 
> templates, but I would prefer to avoid doing something that creates more work 
> and chance of errors if I switch themes.
>
> Is there a better way to do this? I am quite happy to write some Python if 
> necessary.

We suggest overriding the template(s) involved in this. You can use a
custom theme or just the templates folder. Most HTML customizations
will involve overriding a template. You do need to remember about
overrides when you change themes, and it might sometimes be necessary
to check for changes in upstream templates, but this is generally a
minor issue.

>From a quick look, it seems you would need to override
base_helper.tmpl. Since `post` is not always defined, you will need an
if to check that, the easiest way would be to do it via `pagekind`.
And then, you could just do another check for post.meta('canonical')
and insert that instead of the permalink if it’s not blank.

-- 
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

-- 
You received this message because you are subscribed to the Google Groups 
"nikola-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nikola-discuss+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nikola-discuss/CAMw%2Bj7JLDXKJXrq3J4rDW5qDzBVYx32%3DfWrLXdsOvN4vZHpuig%40mail.gmail.com.

Reply via email to