4

I have a standalone html file that contains a sales report, created in R. I have saved the file to the SitePages folder. I have then added a link. When I edit the link and paste in the filepath, I can open the file when I try the link. However, after saving, and trying to open the link, I get a 404 error. The path that works is basically \\mydomain.com\DavWWWRoot\projects\myproject\SitePages\test%20rapport.aspx

However, after saving and trying to open, I can see that the attempted file path is

//projects/myproject/\\mydomain.com\DavWWWRoot\projects\myproject\SitePages\test%20rapport.aspx

Note that the projects/myproject/ is added automatically.

I have tried editing it to /projects/myproject/SitePages/test%20rapport.aspx as it seems like it forces the projects/myproject/ part on the link, but this doesnt work. I am suspecting there might be an issue with escape characters and the slashes.

  • How did you 'save the file to the SitePages folder'? By creating a new file in the library and pasting in the code? Or some other method? – Underverse Jan 10 '18 at 13:24
  • Copy pasted the html\aspx (tried both) file in Windows Explorer – Ullsokk Jan 10 '18 at 13:40
  • 1
    It seems to work in Chrome, but not IE. Sollution for me is just getting users to use Chrome instead – Ullsokk Jan 11 '18 at 11:39
3

First upload the HTML to SharePoint into a document library:

  1. Open Site Contents
  2. Select Add an app
  3. Select Document Library
  4. Name the library
  5. Click Create
  6. Open the library in a web browser e.g. https://sharepoint/sitecollection/sitename/reports/Forms/AllItems.aspx
  7. Upload the HTML files to this library

To display the HTML content on a SharePoint page:

  1. Open Site Contents
  2. Open the Site Pages library
  3. From the ribbon select Files > New Document > Wiki page
  4. Give the page a name then click Create
  5. In the SharePoint page editor select Insert from the ribbon then Web Part then Media and Content category then Content Editor and Add
  6. Click on the Script Editor box, then select Web Part then Web Part Properties from the ribbon
  7. In the Content Link box click the elipsis (...) and find the HTML file to display or paste in the full URL to the HTML file
  8. Click Ok to close the web page dialog
  9. Click Save to save the page

The contents of the HTML file is now displayed on the SharePoint page. You'll need to create an apsx page in this manner for each static HTML page.

The main issue with this approach is that an .aspx file is needed to display the contents of each SharePoint HTML file. The main advantage is that it is easier to upload a HTML file to a document library than it is to upload HTML to the Site Pages library as a wiki page, and the HTML is not garbled or deleted by the SharePoint HTML cleaner. It also easily allows running JavaScript on the HTML page which is harder to do with Site Page content.

The disadvantage is that the hyperlinks between pages need to point to the /SitePages/pagename.aspx instead of the pagename.html. This can easily be fixed in the raw HTML. e.g. Hyperlinks will need to be: <a href= 'reports.aspx'>Reports</a>

Note: To get the full URL for a HTML page go to the Document library, right-click the file name, and select Copy shortcut.

|improve this answer|||||
2

Another option is to store the HTML files in a document library renamed to .aspx so SharePoint serves the content to open in the web browser natively as HTML.

First upload the HTML to SharePoint into a document library:

  1. Open Site Contents
  2. Select Add an app
  3. Select Document Library
  4. Name the library
  5. Click Create
  6. Open the library AllItems view in a web browser - https://sharepoint/sitecollection/sitename/reports/Forms/AllItems.aspx
  7. Rename all of your HTML files from filenname.html to filename.aspx
  8. Upload the .aspx files to this library

The HTML content will now open directly in a web browser.

Go to the document library - Cogwheel > Site contents > Click on the library name or: https://sharepoint/sitecollection/sitename/reports/Forms/AllItems.aspx - and click on a document: https://sharepoint/sitecollection/sitename/reports/index.html

Tested in IE11 and Google Chrome 63.0.3239.132.

The aspx files will have a green * next to their name in the AllItems library view.

|improve this answer|||||
1

If it is static html page you can add it to any document library and change the Farm level property called Browser File Handling to Permissive in SharePoint Central Administration. Then it will open HTML like any file. To change this property:

  1. Go to SPAdmin and logon as a Farm administrator
  2. Open Application Management
  3. Select Web Applications > Manage Web Applications
  4. Click on the name of the web application to change
  5. Click on the General Settings button in the ribbon
  6. Scroll halfway down to the Browser File Handling setting
  7. Change the radio button from strict to permissive
  8. Scroll down to the bottom of the Web Application General Settings panel and click OK

enter image description here

|improve this answer|||||
  • I assume this is a fix on a sys admin level? Not something I can do myself? In that case, I dont see why this would be a good sollution - I believe the file handling is set to strick for a good reason. And I can't get why opening an HTML in a web interface like SharePoint should be any issue at all. Seems so counterintuitive – Ullsokk Jan 11 '18 at 8:25
  • Try to create blank page, add Script Editor web part and insert here your html code. – Semushin Dmitrii Jan 11 '18 at 12:55
  • Tried that also, but no luck – Ullsokk Jan 12 '18 at 11:19
0

Try setting the link as given below and let me know if it works:

/SitePages/test%20rapport.aspx
|improve this answer|||||
  • didnt work for me – Ullsokk Jan 11 '18 at 11:16
  • Can you please try opening sitepages library in browser, right click on the file and copy its url and use it for adding link – Sagar Jan 11 '18 at 14:22
  • Probably needs to be the relative link from the site collection root – Underverse Oct 27 '19 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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