Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi, Unless I am not setting this up correctly, all anchors/fragements are being removed when a link is updated. Is there a way to maintain these anchors?
Comment | File | Size | Author |
---|---|---|---|
#11 | fragment-persist-on-update-2066007-11.patch | 843 bytes | joecorall |
Comments
Comment #1
hass CreditAttribution: hass commentedPuhhh... that's in correct.
The module only takes the 301 redirect url and if this does not provide the anchors/fragments it get's removed. I'm not sure if it's correct to maintain the anchors/fragments if they are not in the 301. It may be useful if you change your site structure without changing your content. If we keep the anchors/fragments on automatic updates it will fail later as the anchors/fragments is now also verified since v1.1. This means we could add this as a new feature. Can you share a patch, please?
I'd like to hear some others if this is the way how it should work (design wise) as I'm not sure... what are web browsers doing here with the anchors/fragments?
Comment #2
plinto CreditAttribution: plinto commentedI'm not sure I understand, so I will explain my situation.
I recently migrated to drupal, but all the links in the pages are the old urls, so basically almost every link on the website is a 301. I want to update all the links with the new drupal generated url. The problem is some links have anchors (and these achors do exist within the linked page) and they are being stripped.
You mention a patch, I would love to able to write one but don't know drupal well enough yet and don't have the skills
Comment #3
hass CreditAttribution: hass commentedMainly I need to know what browsers are doing. Fragments a a bit special. If browser will not keep the fragment on redirects I may not implement it in linkchecker, too. Otherwise if they do, we should also keep the fragment in linkchecker, too.
Comment #4
plinto CreditAttribution: plinto commentedI believe browsers maintain the fragment
Example: If you go to the courses tab on http://www.europe.umuc.edu/undergraduate/bachelors/accounting
All classes have a link with fragment, and all of the links are 301 redirects. If you click one the link is updated and the fragment is maintained
Comment #5
hass CreditAttribution: hass commentedPatch attached (untested)
Comment #6
hass CreditAttribution: hass commentedAnd now without tabs.
Comment #7
hass CreditAttribution: hass commentedAnd now without tabs.
Comment #8
plinto CreditAttribution: plinto commentedThanks, I will test the patch right away
Comment #9
hass CreditAttribution: hass commentedComment #10
hass CreditAttribution: hass commentedAny news on your test results?
Comment #11
joecorall CreditAttribution: joecorall commentedI tested the latest patch, and fragments were not being appended to the end of the new URL.
The test was a drush script with the logic from that patch, with an example old URL and new URL:
And the output shows a failure to add the fragment to the end of the new URL:
So I have attached my own patch which has been tested locally to have "#", and everything afterward, persist in the new URL. I'm submitting the patch to be reviewed by the community.
Comment #12
hass CreditAttribution: hass commented