pelican
pelican copied to clipboard
How to get current filename?
- [x] I have searched the issues (including closed ones) and believe that this is not a duplicate.
- [x] I have searched the documentation and believe that my question is not covered.
Issue
Hi,
Google send me an email about a canonical problem in my site because root website and index.html has the same canonical url:
{% if not PLUGINS or 'seo' not in PLUGINS %}
{% if REL_CANONICAL %}
{% if page %}
<link rel="canonical" href="{{ SITEURL }}/{{ page.url }}">
{% elif article %}
<link rel="canonical" href="{{ SITEURL }}/{{ article.url }}">
{% elif page_name == 'index' and not articles_previous_page %}
<link rel="canonical" href="{{ SITEURL }}">
{% elif author or category or tag or page_name == 'index' %}
<link rel="canonical" href="{{ SITEURL }}/{{ articles_page.url }}">
{% else %}
<link rel="canonical" href="{{ SITEURL }}/{{ output_file }}">
{% endif %}
{% endif %}
{% endif %}
The problem is specific to this line:
<link rel="canonical" href="{{ SITEURL }}">
I need know if im in "https://mysite.com" or "https://mysite.com/index.html".
I search about how to know it, but not found. I search how to write a plugin to export functions to template, but not found.
Can anyone help me?
I don't understand. https://mysite.com/
and https://mysite.com/index.html
are the same thing. They will serve the same file: index.html
(assuming most common server options).
If you just have an URL, https://mysite.com/, you don't need a canonical URL. Canonical URLs are used when you have multiples domains that redirect to the same content. For example, when you have https://mysite.com/ and https://m.mysite.com/ (for display on mobile phones). In this case canonical URLs are useful to make your pages to not compete against each other.
In addition, could you paste the trace or a snapshot of the error? It would help us to help you.
Hey Paulo. If you need further help with this, please post a comment here and we can re-open.
Many thanks to @avaris and @emibarrod for helping out!