Skip to content

feat: Add canonical=false option to disable canonical URL output#521

Open
rathboma wants to merge 1 commit intojekyll:masterfrom
beekeeper-studio:feature/canonical-false-option
Open

feat: Add canonical=false option to disable canonical URL output#521
rathboma wants to merge 1 commit intojekyll:masterfrom
beekeeper-studio:feature/canonical-false-option

Conversation

@rathboma
Copy link

Summary

Adds a new canonical=false option to disable the <link rel="canonical"> tag output, similar to the existing title=false option.

Use Case

When using multilingual plugins like jekyll-polyglot, the canonical URL needs special handling:

  • Translated pages should have canonical URLs pointing to their language-specific URLs
  • Fallback pages (using default language content) may need canonical URLs pointing to the default language version

By allowing users to disable the canonical output from jekyll-seo-tag, they can use their multilingual plugin's canonical URL generation instead.

Usage

{% seo canonical=false %}

This disables only the <link rel="canonical"> tag while still outputting all other SEO tags including <meta property="og:url">.

Changes

  • Added canonical? method to Drop class (similar to title?)
  • Updated template to conditionally output canonical tag
  • Added unit tests for canonical? method
  • Added integration tests for canonical=false
  • Updated advanced-usage.md documentation

Testing

All 222 existing tests pass, plus 5 new tests for the canonical feature.


🤖 Generated with Claude Code

Similar to the existing title=false option, this allows users to disable
the canonical URL output when using other plugins (like jekyll-polyglot)
to generate canonical URLs for multilingual sites.

Usage: {% seo canonical=false %}

This disables the <link rel="canonical"> tag while still outputting
the <meta property="og:url"> tag.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
rathboma added a commit to rathboma/polyglot that referenced this pull request Jan 14, 2026
Instead of trying to exclude canonical URLs from relativization via
regex (which was complex and error-prone), recommend using jekyll-seo-tag's
new `canonical=false` option combined with Polyglot's I18n_Headers tag.

This provides cleaner separation of concerns:
- jekyll-seo-tag handles all SEO tags except canonical
- Polyglot's I18n_Headers handles canonical and hreflang tags with
  proper translation detection

Changes:
- Remove canonical exclusion from absolute_url_regex
- Update README to document jekyll-seo-tag integration
- Remove test for canonical regex exclusion

Related: jekyll/jekyll-seo-tag#521

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mattr- mattr- self-assigned this Jan 17, 2026
@mattr-
Copy link
Member

mattr- commented Jan 17, 2026

@rathboma this looks good. thanks for the contribution! If you could fix up the style guide issues, that would unblock merging this. I've pulled them out of the action to make it easier

lib/jekyll-seo-tag/drop.rb:38:16: C: Naming/MemoizedInstanceVariableName: Memoized variable @display_canonical does not match method name canonical?. Use @canonical instead.
        return @display_canonical if defined?(@display_canonical)
               ^^^^^^^^^^^^^^^^^^
lib/jekyll-seo-tag/drop.rb:38:47: C: Naming/MemoizedInstanceVariableName: Memoized variable @display_canonical does not match method name canonical?. Use @canonical instead.
        return @display_canonical if defined?(@display_canonical)
                                              ^^^^^^^^^^^^^^^^^^
lib/jekyll-seo-tag/drop.rb:40:9: C: Naming/MemoizedInstanceVariableName: Memoized variable @display_canonical does not match method name canonical?. Use @canonical instead.
        @display_canonical = (@text !~ %r!canonical=false!i)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants