Create multiple HTMLs for the same markdown files (Hugo docuapi) - amazon-cloudfront

I am using Docuapi theme with Hugo.
The docuapi theme combines all markdown files into one and generates a single HTML file.
I am using a Consent Management system to display a cookie consent banner.
The site is deployed using Cloudfront CDN.
I want to display the consent banner only for the requests coming from a certain region.
Is it possible to generate two different html files out of hugo for the same markdown files, with the same URL structure, and load them depending on which region the request is coming from?
I can setup my CDN to access different files based on the request.
Any ideas?

Yes, you can reuse content easily by doing this in your partial/layout/shortcode:
{{ with $.Site.GetPage 'yourmarkdownfile.md' }}{{ .Content }}{{ end }}
Can that be a starting point for a solution?

Related

Adding HTML from an internal file to a Web Part on SharePoint

I have developed a SharePoint Web Part where I have an iframe that I need to load with several pages depend on different values.
For instance, I have this files
file1.html
file2.html
file3.html
And I need to pass the path of one of this elements to an iframe
Where can I put this files and How can I retrieve the right path of this pages?
Regards
Try to save the html files in a library and set the iframe url dynamically.
$('#iframeId').attr('src', url)

Making Content Editable with Netlify CMS and Hugo

I'm trying to wrap my head around how I can go into the Netlify CMS and be able to edit the home page texts using Hugo. Days of research is leading me nowhere since all documents are about doing blog posts.
Right now I have my Netlify config.yml in the static/admin and an index.html file in the layouts folder. What do I need to do to be able to go into the Netlify dashboard and edit fields which will change texts on home page?
If I were to make the index.html as a markdown file in the content folder, how can I pull that data within the index.md to the index.html that lives in the layout folder?
If netlifycms is already in the site and that site is on netlify, then the next step is to add your account as a user to the site.
Open the site in the app.netlify.com/sites
Click on the Identity tab
Invite users
Accept invitation
Open up YOURDOMAIN.COM/admin page
Netlify will prompt for a login
I've had the same problem figuring out how to do netlifycms. Instructions are generally weak on where one does what. Sometimes creating an account/password is also problematic. Good luck!
Your index.html would need to be something like:
{{ define "main" }}
<article>
<h1>{{.Title}}</h1>
{{.Content}}
<!-- any other homepage html -->
</article>
{{ end }}
And then that will be populated with the content of content/_index.md in the same way as any other content page.
---
title: My homepage
date: 2020-04-24T10:48:46.000Z
---
User-editable homepage content, easily managed with Netlify CMS
Contents for the home page has to be in content/_index.md (or _index.en.md for multilingual).
If your netlify-cms config for pages collection does not match this (for example if you keep your pages in content/pages/*.md), then you need a special collection configured with file: content/_index.md.

Should Azure CDN typically be used for serving images (other than static layout elements)?

So, in a scenario where we have web site/app that has some static images (layout parts, icons, etc...) and some images within the actual content (user posts containing images, e.g.) - is it usual/preferable to use CDN in both cases or is it more common to use CDN for static content and without CDN (blob storage directly) for content images?
Here is a good SO answer about this, and the following is the related info:
You can go with CDN if you want, but it's best to use CDN for infrequently-changing content (as you can't forcibly expire the content). So, if you have some CSS, background images, etc. that don't change too often, those are great CDN candidates. If it's a daily-changing front-page HTML file, I would skip CDN on that one.
Hope it helps.

what is the ''/home" after the website domain name?

I'm new to web development and i want to ask that why some website have the "/"?
for example https://www.roblox.com/home, notice the "/home" what does that called
I have tried to search on google and i can't find the answer
And some website have like "/login.php", "/index.html" it can also be html?
These are URLs (https://en.wikipedia.org/wiki/URL) and they identify the resource you are trying to reach. I would suggest reading more about how web pages works to get a better general overview of things(e.g.: https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/How_the_Web_works)
How these resources are actually interpreted depends on the server side implementation:
.php are usually processed by PHP web server
Other static files such as images (*.png , *.jpg, etc), html files, svgs, CSS, js, etc - Are usually located in the local server by the web server (httpd, tomcat, IIS, nodejs, and many many others) and the files as transmitted to the client 'as-is'
When using online tools to build websites, these complexities are usually abstracted away, and in the end URLs will just mean a resource identifier.
[domain]/[section]/[page(.html|.php)|resource(.js|.css)]
domain: the address of the website
section: a way to navigate inside the website itself
page: the user interface that might be rendered server side of client side hold the controls shown to user
resource: files that changes how the content in the pages looks and behaves like

Links on SharePoint 2010 Master Page not changed based on Alternate Access Mappings

We are creating a custom branded Master Page in SharePoint 2010. To make the page similar to a legacy page we have implemented an html based custom dropdown navigation menu we had in place directly on the Master Page (consisted of basic HTML elements ULs and LIs with A tags styled with a CSS class).
I assumed the links from the basic HTML on the page would be subject to Alternate Access Mappings currently in place, but it seems to not be the case. On a test page opened in 3 different URLs (http://sharepoint2010, http://sharepoint2010.mydomain.com, https://sharepoint2010.mydomain.com) the links from a WIKI page are modified as I expected, but the links from the Custom Navigation Menu (plain HTML on the Master Page) are not modified.
I can see where that would be useful... But is there a way that I can add links on the MasterPage in a way that SharePoint parses them first, making them subject to Alternate Access Mapping translation? I tried placing a link inside a SPLinkButton control, but it didn't achieve the desired behavior.
e.g.
<ul id="navmenu">
<li><SharePoint:SPLinkButton runat="server" NavigateUrl="http://sharepoint2010">sharepoint link</SharePoint:SPLinkButton></li>
<li>sharepoint2010</li>
<li>test</li>
</ul>
When I access the page via https://sharepoint2010.mydomain.com the links above are still http://sharepoint2010 rather than https://sharepoint2010.mydomain.com
Any thoughts?
Thanks,
Victor
EDIT (clarify):
I was planning on using relative links as a fallback. But for the purpose of what we are doing it would be more maintainable if we could keep the full links and use AAM.
I'm aware that standard relative links are a possibility. I was hoping to identify if there is a way to use AAM on Master Page content (or even on Content Retrieved from External Services down the road) by providing a specific link syntax, or control framework.
There is no need to re-insert the host name if your links are on the same domain and you're not using managed paths. Keeping your links relative will ensure that any bindings in IIS and AAM setup in SharePoint will work without any additional work.
Otherwise, I would heavily suggest to use the available ~sitecollection and ~site SPUrl token to retrieve the current site collection url or current web url. You need to wrap it in anything running server side as the expression will be handled ... server side.
eg:
<asp:Literal runat="server" Text="<% $SPUrl:~site/press-releases/ %>"/>
Hope it helped
When you use the NavigateUrl= attribute of the SPLinkButton, SharePoint renders a simple anchor with href= instead of regular PostBack JavaScript code. Alternate access mapping do not play a role here.
If its simply relative links you want, then leave out the dns entry altogether (ie the bit of the url you are switching with your AAM) and begin the url with a forward slash to make it relative. If this doesn't meet your needs, the way Sharepoint does it is with a relative url token. Have a look in v4.master for the tilda character followed by 'site' or 'sitecollection' which refers to the current web and site collection respectively. Copy this method. For more details, look at this link: http://msdn.microsoft.com/en-us/library/ms473643.aspx

Resources