0

I have a relatively complex html-structure in a document library, which I want to display in a web part. The web part refers to site.com/library/index.htm, from which other pages are called.

Problems occur with the relative paths. site.com/library/index.htm is calling <a href="page1.htm">Page 1</a> which results into site.com/library/page1.htm. But the index.htm within webpart just calls site.com/page1.htm.

Is there any way to change this behaviour without adding ../library/ to every single link? Editing every link in a couple of dozen files does not look like an appealing solution. :/

2 Answers 2

1

I'm afraid there is no other way than updating all the htm files. In SharePoint relative paths does not work that way, even if index.htm resides inside the Library.. href='page1.html' would simply mean rootsite/page1.htm

Not even the inner site collection will be placed, that means if you have rootsite/sites/innersite/library/page1.htm and you refer it as href='page1.htm', this would simply mean rootsite/page1.htm

1

Maybe you can use the BASE tag

<head>
  <base href="[url]">
</head>
5
  • That would help very much, but it does not seem to work for me. I couldn't even create a minimal working example. Is <base> supported by SharePoint?
    – wheeler
    Aug 4, 2015 at 7:53
  • It is HTML and supported by all Browsers. I think the issue is you need to specificy this in the HEAD, so it won't help you when putting the code in a WebPart. I have never used it in combo with SharePoint. Aug 4, 2015 at 10:38
  • Hm, seems like I misunderstand something. I created a html and displayed this html with the Content Editor -> not working. If I display this html with the Page Viewer WebPart, everything works fine. Do I use the Content Editor WebPart in the wrong way? I mostly just display html-files with the Content Editor.
    – wheeler
    Aug 4, 2015 at 11:28
  • Do you put the content in the CEWP or do you specifiy a link to the file. The last one is way more flexible as you can open the file in any IDE Aug 4, 2015 at 13:09
  • I have a content.html and the CEWP is just linking to this content.html. I do not modify the html-markup inside the CEWP. However the PVWP is working fine for me, I was just not aware that PVWP behaves differently than CEWP.
    – wheeler
    Aug 4, 2015 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.