Announcement

#1 2019-12-30 10:38:22

J0nny
Member
2017-12-15
31

Change Canonical to album url

Hi,

with every photo in my Piwigo gallery, there are two possible pages, one with the category ( album ) and one without. My limited understanding of php is that the Canonical Tag is used to tell search engines which is the preferred version. Reading the source file of the two alternatives, I see that the preferred or canonical version is the version without a category.  Is it possible to change this so that the preferred version is the version with a category, or even to change it so that the only version is the one with the category.

The reason is categories are very important to the working of my gallery. Visitors find my gallery in search engines and if they are directed to just a page without a category, when when they click the sides of the images, or the navigation arrows, they are pointed to images in different categories which are of no interest. For example they may have searched for a photo of "London". If they arrive at a page with no categories, then the next page will probably be a different city. Most people searching for pictures of London have no interest in other cities, so I would like them to arrive at the URL with the album / category. That way when they click the navigation they will see other similar photographs.

I am sure this is relevant to many other piwigo users galleries. My gallery is organised geographically but the same would be true for an animal photographer who has a separate album for each species. Thus he would want a search for "Tiger" to land in an album full of Tiger photos, not just a random collection of different animals.

Here are two example URLs

https://www.webbaviation.co.uk/aerial/p … tegory/783

( with Album/ category )

https://www.webbaviation.co.uk/aerial/p … php?/15075

( Without album / category )

I only want the first URL with the category.

Having 2 URLs is confusing for my visitors and very bad for search engine optimisation as all my links include the category.




regards,

Jonny

Piwigo 2.10.1 
Operating system: Linux
PHP: 5.6.40 (Show info) [2019-11-04 15:03:34]
MySQL: 5.6.42-log [2019-11-04 15:03:34]
Graphics Library: External ImageMagick 7.0.8-50

Offline

 

#2 2019-12-30 14:02:28

erAck
Only trying to help
2015-09-06
1396

Re: Change Canonical to album url

Without category is the canonical URI because a picture can be associated with multiple albums or categories or may appear in the Recent Photos or Most Visited or any other buckets.

Assignment of the canonical URI is done in picture.php with $template->assign(), search for U_CANONICAL where make_picture_url() is called. For your case, iff called from a category page the params array could include a categories section, see include/functions_url.inc.php the implementation of make_picture_url() and make_section_in_url(). Not sure how to actually determine whether the call is from a category's page. Maybe someone wants to take a look at this and come up with a solution, best configurable.


Running Piwigo at https://erack.net/gallery/

Offline

 

#3 2019-12-30 14:27:44

J0nny
Member
2017-12-15
31

Re: Change Canonical to album url

Thanks for your help. I have found and looked at the relevant files but unfortunately editing php is beyond my skill level. The most I can manage are copy paste alterations following directions from others.

Hopefully in the future there may be an option to set this in the user interface. Currently each image can be called in an album, in tags, in most viewed and in latest images, or just on its own. I think it would be easier for both visitors and search engines if the image was only called in an album / category.

As a basic work around , for visitors I have put a notice under the photo suggesting they the click on the album menu and for search engines I have added a link to the sitemap at the bottom of the page. This is, however very messy. I am having Human visitors going through one set of menus and urls while search engines are going through a different set of URLs. Having each image on several possible URLs probably down ranks the page rank for all of them.

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2022 · Contact