Setting base path breaks anchor links2019 Community Moderator ElectionWhat are the recommendations for html <base> tag?Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?Set cellpadding and cellspacing in CSS?Should I make HTML Anchors with 'name' or 'id'?Tab space instead of multiple non-breaking spaces (“nbsp”)?How to create an HTML button that acts like a link?How can I set the default value for an HTML <select> element?offsetting an html anchor to adjust for fixed headerOpen link in new tab or windowHow to print the link of a category into the href=“” of an anchor tag in Wordpress?Cannot display HTML string

Is it normal that my co-workers at a fitness company criticize my food choices?

Why did it take so long to abandon sail after steamships were demonstrated?

In a future war, an old lady is trying to raise a boy but one of the weapons has made everyone deaf

What is the domain in a tikz parametric plot?

Why doesn't using two cd commands in bash script execute the second command?

How Could an Airship Be Repaired Mid-Flight

What are the naunces between the use of 訊く instead of 聞く in the following sentence?

If curse and magic is two sides of the same coin, why the former is forbidden?

My adviser wants to be the first author

Recruiter wants very extensive technical details about all of my previous work

What is the significance behind "40 days" that often appears in the Bible?

What's the meaning of “spike” in the context of “adrenaline spike”?

Look at your watch and tell me what time is it. vs Look at your watch and tell me what time it is

How difficult is it to simply disable/disengage the MCAS on Boeing 737 Max 8 & 9 Aircraft?

Are there verbs that are neither telic, or atelic?

Is a party consisting of only a bard, a cleric, and a warlock functional long-term?

Welcoming 2019 Pi day: How to draw the letter π?

What options are left, if Britain cannot decide?

The hookrightarrow and its meaning

How to simplify this time periods definition interface?

How big is a MODIS 250m pixel in reality?

Most cost effective thermostat setting: consistent temperature vs. lowest temperature possible

How to make healing in an exploration game interesting

Do I need to be arrogant to get ahead?



Setting base path breaks anchor links



2019 Community Moderator ElectionWhat are the recommendations for html <base> tag?Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?Set cellpadding and cellspacing in CSS?Should I make HTML Anchors with 'name' or 'id'?Tab space instead of multiple non-breaking spaces (“nbsp”)?How to create an HTML button that acts like a link?How can I set the default value for an HTML <select> element?offsetting an html anchor to adjust for fixed headerOpen link in new tab or windowHow to print the link of a category into the href=“” of an anchor tag in Wordpress?Cannot display HTML string










0















I have created a WordPress theme and the images in it were all broken so I added a base path tag to the page.



<base href="https://www.example.com/wp/wp-content/themes/my-theme/"/>


But now all of the anchor / links don't work.



<a href="#an_id_on_the_page">click here</a>


The above link points to "https://www.example.com/wp/wp-content/themes/my-theme/index.php#an_id_on_the_page" instead of the same page but further down.



WordPress recommends adding "" to the path of every image. But that means breaking a workflow and editing the HTML code on every change.



Are there any ideas to fix this?



UPDATE

It looks like if I put a "/" in front of the anchor it looks like it is working. I'll test it some more to confirm.










share|improve this question
























  • I think you copied and pasted your code here incorrectly. Note the extension: image.png rather than index.php. It makes little sense to make your base path point to an image...

    – Heretic Monkey
    Mar 6 at 20:19















0















I have created a WordPress theme and the images in it were all broken so I added a base path tag to the page.



<base href="https://www.example.com/wp/wp-content/themes/my-theme/"/>


But now all of the anchor / links don't work.



<a href="#an_id_on_the_page">click here</a>


The above link points to "https://www.example.com/wp/wp-content/themes/my-theme/index.php#an_id_on_the_page" instead of the same page but further down.



WordPress recommends adding "" to the path of every image. But that means breaking a workflow and editing the HTML code on every change.



Are there any ideas to fix this?



UPDATE

It looks like if I put a "/" in front of the anchor it looks like it is working. I'll test it some more to confirm.










share|improve this question
























  • I think you copied and pasted your code here incorrectly. Note the extension: image.png rather than index.php. It makes little sense to make your base path point to an image...

    – Heretic Monkey
    Mar 6 at 20:19













0












0








0








I have created a WordPress theme and the images in it were all broken so I added a base path tag to the page.



<base href="https://www.example.com/wp/wp-content/themes/my-theme/"/>


But now all of the anchor / links don't work.



<a href="#an_id_on_the_page">click here</a>


The above link points to "https://www.example.com/wp/wp-content/themes/my-theme/index.php#an_id_on_the_page" instead of the same page but further down.



WordPress recommends adding "" to the path of every image. But that means breaking a workflow and editing the HTML code on every change.



Are there any ideas to fix this?



UPDATE

It looks like if I put a "/" in front of the anchor it looks like it is working. I'll test it some more to confirm.










share|improve this question
















I have created a WordPress theme and the images in it were all broken so I added a base path tag to the page.



<base href="https://www.example.com/wp/wp-content/themes/my-theme/"/>


But now all of the anchor / links don't work.



<a href="#an_id_on_the_page">click here</a>


The above link points to "https://www.example.com/wp/wp-content/themes/my-theme/index.php#an_id_on_the_page" instead of the same page but further down.



WordPress recommends adding "" to the path of every image. But that means breaking a workflow and editing the HTML code on every change.



Are there any ideas to fix this?



UPDATE

It looks like if I put a "/" in front of the anchor it looks like it is working. I'll test it some more to confirm.







html






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 6 at 20:37







1.21 gigawatts

















asked Mar 6 at 19:53









1.21 gigawatts1.21 gigawatts

6,1002164129




6,1002164129












  • I think you copied and pasted your code here incorrectly. Note the extension: image.png rather than index.php. It makes little sense to make your base path point to an image...

    – Heretic Monkey
    Mar 6 at 20:19

















  • I think you copied and pasted your code here incorrectly. Note the extension: image.png rather than index.php. It makes little sense to make your base path point to an image...

    – Heretic Monkey
    Mar 6 at 20:19
















I think you copied and pasted your code here incorrectly. Note the extension: image.png rather than index.php. It makes little sense to make your base path point to an image...

– Heretic Monkey
Mar 6 at 20:19





I think you copied and pasted your code here incorrectly. Note the extension: image.png rather than index.php. It makes little sense to make your base path point to an image...

– Heretic Monkey
Mar 6 at 20:19












1 Answer
1






active

oldest

votes


















1














No links or named anchors or blank hrefs will point to the original subdirectory, unless that is made explicit: The base tag makes everything link differently, including same-page anchor links to the base tag's url instead, e.g:



<a href='#top-of-page' title='Some title'>A link to the top of the page via a named anchor</a>
becomes
<a href='http://www.example.com/other-subdirectory/#top-of-page' title='Some title'>A link to an #named-anchor on the completely different base page</a>

<a href='?update=1' title='Some title'>A link to this page</a>
becomes
<a href='http://www.example.com/other-subdirectory/?update=1' title='Some title'>A link to the base tag's page instead</a>


With some work, you can fix these problems on links that you have control over, by explicitly specifying that these links link to the page that they are on, but when you add third-party libraries to the mix that rely on the standard behavior, it can easily cause a big mess.



Resource,






share|improve this answer























  • Hi @Dasun. That's right. I was doing some reading and a / will point to the root directory. Since WP reads in the page content and then writes it back out I was able to add a / before #myanchor and this appears to be working. I've updated my answer.

    – 1.21 gigawatts
    Mar 6 at 20:18











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031195%2fsetting-base-path-breaks-anchor-links%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














No links or named anchors or blank hrefs will point to the original subdirectory, unless that is made explicit: The base tag makes everything link differently, including same-page anchor links to the base tag's url instead, e.g:



<a href='#top-of-page' title='Some title'>A link to the top of the page via a named anchor</a>
becomes
<a href='http://www.example.com/other-subdirectory/#top-of-page' title='Some title'>A link to an #named-anchor on the completely different base page</a>

<a href='?update=1' title='Some title'>A link to this page</a>
becomes
<a href='http://www.example.com/other-subdirectory/?update=1' title='Some title'>A link to the base tag's page instead</a>


With some work, you can fix these problems on links that you have control over, by explicitly specifying that these links link to the page that they are on, but when you add third-party libraries to the mix that rely on the standard behavior, it can easily cause a big mess.



Resource,






share|improve this answer























  • Hi @Dasun. That's right. I was doing some reading and a / will point to the root directory. Since WP reads in the page content and then writes it back out I was able to add a / before #myanchor and this appears to be working. I've updated my answer.

    – 1.21 gigawatts
    Mar 6 at 20:18
















1














No links or named anchors or blank hrefs will point to the original subdirectory, unless that is made explicit: The base tag makes everything link differently, including same-page anchor links to the base tag's url instead, e.g:



<a href='#top-of-page' title='Some title'>A link to the top of the page via a named anchor</a>
becomes
<a href='http://www.example.com/other-subdirectory/#top-of-page' title='Some title'>A link to an #named-anchor on the completely different base page</a>

<a href='?update=1' title='Some title'>A link to this page</a>
becomes
<a href='http://www.example.com/other-subdirectory/?update=1' title='Some title'>A link to the base tag's page instead</a>


With some work, you can fix these problems on links that you have control over, by explicitly specifying that these links link to the page that they are on, but when you add third-party libraries to the mix that rely on the standard behavior, it can easily cause a big mess.



Resource,






share|improve this answer























  • Hi @Dasun. That's right. I was doing some reading and a / will point to the root directory. Since WP reads in the page content and then writes it back out I was able to add a / before #myanchor and this appears to be working. I've updated my answer.

    – 1.21 gigawatts
    Mar 6 at 20:18














1












1








1







No links or named anchors or blank hrefs will point to the original subdirectory, unless that is made explicit: The base tag makes everything link differently, including same-page anchor links to the base tag's url instead, e.g:



<a href='#top-of-page' title='Some title'>A link to the top of the page via a named anchor</a>
becomes
<a href='http://www.example.com/other-subdirectory/#top-of-page' title='Some title'>A link to an #named-anchor on the completely different base page</a>

<a href='?update=1' title='Some title'>A link to this page</a>
becomes
<a href='http://www.example.com/other-subdirectory/?update=1' title='Some title'>A link to the base tag's page instead</a>


With some work, you can fix these problems on links that you have control over, by explicitly specifying that these links link to the page that they are on, but when you add third-party libraries to the mix that rely on the standard behavior, it can easily cause a big mess.



Resource,






share|improve this answer













No links or named anchors or blank hrefs will point to the original subdirectory, unless that is made explicit: The base tag makes everything link differently, including same-page anchor links to the base tag's url instead, e.g:



<a href='#top-of-page' title='Some title'>A link to the top of the page via a named anchor</a>
becomes
<a href='http://www.example.com/other-subdirectory/#top-of-page' title='Some title'>A link to an #named-anchor on the completely different base page</a>

<a href='?update=1' title='Some title'>A link to this page</a>
becomes
<a href='http://www.example.com/other-subdirectory/?update=1' title='Some title'>A link to the base tag's page instead</a>


With some work, you can fix these problems on links that you have control over, by explicitly specifying that these links link to the page that they are on, but when you add third-party libraries to the mix that rely on the standard behavior, it can easily cause a big mess.



Resource,







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 6 at 20:11









Dasun ManathungaDasun Manathunga

313




313












  • Hi @Dasun. That's right. I was doing some reading and a / will point to the root directory. Since WP reads in the page content and then writes it back out I was able to add a / before #myanchor and this appears to be working. I've updated my answer.

    – 1.21 gigawatts
    Mar 6 at 20:18


















  • Hi @Dasun. That's right. I was doing some reading and a / will point to the root directory. Since WP reads in the page content and then writes it back out I was able to add a / before #myanchor and this appears to be working. I've updated my answer.

    – 1.21 gigawatts
    Mar 6 at 20:18

















Hi @Dasun. That's right. I was doing some reading and a / will point to the root directory. Since WP reads in the page content and then writes it back out I was able to add a / before #myanchor and this appears to be working. I've updated my answer.

– 1.21 gigawatts
Mar 6 at 20:18






Hi @Dasun. That's right. I was doing some reading and a / will point to the root directory. Since WP reads in the page content and then writes it back out I was able to add a / before #myanchor and this appears to be working. I've updated my answer.

– 1.21 gigawatts
Mar 6 at 20:18




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55031195%2fsetting-base-path-breaks-anchor-links%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко